Get text from webbrowser... [solved]

Posts 1–4 of 4 · Page 1 of 1
Get text from webbrowser... [solved]
I know i remember posting something similar and @Jason solved it for me. but i cannot find where it is..

How would i get text from a webbrowser .txt file..

(eg) webbrowser has the word "hi" and i want the label to have the same as the browser


I do remember some of the code something along the lines of

Code:
If WebBrowser1.DocumentText.ToString.ToLower = "Hi" Then
            Label2.Text = WebBrowser1.DocumentText.ToString.ToLower
        End If
but the label wont read it!

Any help?
Code:
If WebBrowser1.DocumentText.ToLower = "hi" Then
     Label2.Text = WebBrowser1.DocumentText.ToLower
End If
The string "Hi" has to match ToLower so instead it should be "hi". If you converted it ToUpper then you would do "HI". Also DocumentText is already a string so doing .ToString is unnecessary.

--

If the word "Hi" isn't the only string on the web page and you still need to check if it on the page you would do

Code:
If WebBrowser1.DocumentText.ToLower.Contains("hi") Then
     Label2.Text = WebBrowser1.DocumentText.ToLower
End If
Quote Originally Posted by NOOB View Post
Code:
If WebBrowser1.DocumentText.ToLower = "hi" Then
     Label2.Text = WebBrowser1.DocumentText.ToLower
End If
The string "Hi" has to match ToLower so instead it should be "hi". If you converted it ToUpper then you would do "HI". Also DocumentText is already a string so doing .ToString is unnecessary.

--

If the word "Hi" isn't the only string on the web page and you still need to check if it on the page you would do

Code:
If WebBrowser1.DocumentText.ToLower.Contains("hi") Then
     Label2.Text = WebBrowser1.DocumentText.ToLower
End If
Thanks, I didn't know that, and I couldn't figure out why my text was always in caps.
I knew it was something like that, Thanks noob

but that doesnt work still, That code give's me the source of the webpage

edit 2: i ended up using
Code:
Dim myText As String = Me.WebBrowser1.Document.Body.InnerText
Posts 1–4 of 4 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us