If webpage contains text like "username invalid"...

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
7 posts Page 1 of 1
Contributors
User avatar
patrickcosta
New Member
New Member
Posts: 16
Joined: Wed Jun 27, 2012 8:59 pm

Hi, Sorry for the subject but I didn't know what better to put...

Well, I have a register form in my vb and I'd like to know how to put this:
If when a user click register and in webpage appears a text saing; your username is invalid. choose another one.

The webbrowser is hide in the form, because I 'redirect' the white spaces to textbox's and submit button to a button1.

I'd like to know how to inform that user (with a msgbox or something) that his username is invalid. How to do this ?

Sorry my english :s

EDIT: here is the register webpage: http://patrickcosta.forumeiros.com/regi ... rue&step=2
User avatar
Cheatmasterbw
Coding God
Coding God
Posts: 1506
Joined: Fri Jan 01, 2010 2:30 pm

something like this:
Code: Select all
if webbrowser1.documenttext.contains("Your username is invalid") then
    webbrowser1.visible = false
    msgbox("The username/password is invalid")
end if
You can put the textboxes and the submit button behind the web browser.
http://www.megaapps.tk/
User avatar
patrickcosta
New Member
New Member
Posts: 16
Joined: Wed Jun 27, 2012 8:59 pm

thanks for the answer but I didn't explained, sorry:
when I click in register button the page will go to another one and I want to search if that words are in that new page . confuse ? :S

Thanks in Advance
User avatar
Cheatmasterbw
Coding God
Coding God
Posts: 1506
Joined: Fri Jan 01, 2010 2:30 pm

i think you can use the code i gave you in the web browser's page_load (or something like that) event.
http://www.megaapps.tk/
User avatar
comathi
Coding God
Coding God
Posts: 1242
Joined: Fri Mar 26, 2010 1:59 pm

Actually, you might want to place it in the WebBrowser DocumentCompleted event so that it executes the code when the page has finished loading.
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Code: Select all
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
   If WebBrowser1.DocumentText.Contains("Your username is invalid") Then
       MessageBox.Show("The username you chose is invalid")
   End If
End Sub
Something like that I guess
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
patrickcosta
New Member
New Member
Posts: 16
Joined: Wed Jun 27, 2012 8:59 pm

MrAksel wrote:
Code: Select all
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
   If WebBrowser1.DocumentText.Contains("Your username is invalid") Then
       MessageBox.Show("The username you chose is invalid")
   End If
End Sub
Something like that I guess
Using this code it will search "Your username is invalid" every pages or only in the first ?

Thanks everyone :)

EDIT: I tested now and was this I was searching!
7 posts Page 1 of 1
Return to “Coding Help & Support”