title: Wait Till WebBrowser Load? (VB 2010)
body: <p>I have searched and searched for code and everything I have tried does not work.
  Basically I need the WebBrowser to fully load before running a test code...</p>
  
  <pre><code>Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  
      WebBrowser1.Document.GetElementById("login").SetAttribute("value", TextBox1.Text)
      WebBrowser1.Document.GetElementById("passwd").SetAttribute("value", TextBox2.Text)
      WebBrowser1.Document.GetElementById("SI").InvokeMember("Click")
  
      Where I need to insert the WaitForPageLoad()
  
  
      RichTextBox1.Text = WebBrowser1.DocumentText
      If InStr(RichTextBox1.Text, "To continue, create an Xbox profile") Then
          MsgBox("You do not have an xbox account associated with this gamertag, please log into xbox.com with the account then create an xbox profile.")
      Else
          MsgBox("nothing")
  
      End If
  </code></pre>
  
  <p>As you can see I tried to use a script to make me log into Xbox.com, and it does work, but just a little bit. The process of this code is TOO fast, it isn't checking the right source code for the string saying "To continue...", basically </p>
  
  <pre><code>    WebBrowser1.Document.GetElementById("login").SetAttribute("value", TextBox1.Text)
      WebBrowser1.Document.GetElementById("passwd").SetAttribute("value", TextBox2.Text)
      WebBrowser1.Document.GetElementById("SI").InvokeMember("Click")
  </code></pre>
  
  <p>After it does that click, It clicks the button that does the log in process, but it has to load a whole new page, the problem with this is that it executes the next line of code way too fast and the next line of code searches for that string in the wrong source code. I need it to WAIT for that page to load, then run this line</p>
  
  <pre><code>RichTextBox1.Text = WebBrowser1.DocumentText
  </code></pre>
  
  <p>Which copies the sourcecode of the webbrowser to a textbox which then is searched for the string. I have tried everything. I feel like WaitForPageLoad() would work great but I get an error telling me it isn't declared. Can anyone help?</p>