VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Retrieve Values from Web Page (WebBrowser Control)

by Stephen B. Gauntt (1 Submission)
Category: VB function enhancement
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

Allows you to retrieve values from fields (i.e. hidden fields) in a web page loaded using the WebBrowser control. Very simple function, but I've found it extremely useful. Please don't forget to leave a comment to let me know what you think!
To call this function try this example:
MyValue = GetWebValue(MyWebBrowser,"fieldname")
Will return the value or nothing if not found.

Rate Retrieve Values from Web Page (WebBrowser Control)

Function GetWebValue(WebBrowser As WebBrowser, value As String)
 'Checking if a Frame Page is being displayed
 On Error GoTo EndStuff:
 Set LkpWeb = WebBrowser.Document
 If LkpWeb.Frames.Length > 0 Then
 'Cycle through the frames
 For i = 0 To LkpWeb.Frames.Length - 1
 Set Lkp = LkpWeb.Frames(i).Document.All
 On Error Resume Next
 GetWebValue = Lkp.Item(CStr(value)).value
 If Err.Number = 0 Then
 Exit For
 End If
 DoEvents
 Next
 Else
 Set LkpWeb = WebBrowser.Document.All
 On Error Resume Next
 GetWebValue = LkpWeb.Item(CStr(value)).value
 End If
EndStuff:
End Function

Download this snippet    Add to My Saved Code

Retrieve Values from Web Page (WebBrowser Control) Comments

No comments have been posted about Retrieve Values from Web Page (WebBrowser Control). Why not be the first to post a comment about Retrieve Values from Web Page (WebBrowser Control).

Post your comment

Subject:
Message:
0/1000 characters