Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
01-31-2005, 05:52 AM #1
- Join Date
- Sep 2002
- Thanked 1 Time in 1 Post
[vb] How do you pull a specific string from an html doc?
Ive been working on this program for some time now and ive run into a snag, I need to be able to pull a certain string from an html document and set up a conditional statement like.
If string="text" then
Elseif string="bleh" then
Ive done alot of searching on the net and have found one example of how to find text in an html document, the code is below.
Private Sub Command1_Click() 'The command you would use for this 'function should look a bit like 'this: If WebPageContains( _ "Hello how are you today?") = True Then MsgBox "The webpage contains the text" End If End Sub Private Function WebPageContains(ByVal s As String) As Boolean Dim i As Long, HTMLElement 'Change the "WebBrowser1" to the 'name of your Web Browser in the 'next two lines of code. For i = 1 To WebBrowser1.Document.All.length Set HTMLElement = _ WebBrowser1.Document.All.Item(i) If Not (HTMLElement Is Nothing) Then If InStr(1, HTMLElement.innerHTML, _ s, vbTextCompare) > 0 Then WebPageContains = True Exit Function End If End If Next i End FunctionWhen traveling down the road of life, Try not to drag your face in the gravel.
02-01-2005, 10:46 AM #2
- Join Date
- Aug 2004
- Thanked 0 Times in 0 Posts
*this message will self destruct in n-seconds*