title: WebBrowser control and ready state
body: <p>I am using a webbrowser control to login to a website.</p>
  
  <pre><code>WbBrowser.Navigate("http://www.foo.com/login.php")
  </code></pre>
  
  <p>Once the page is loaded I login using the following code</p>
  
  <pre><code>While WbBrowser.ReadyState &lt;&gt; WebBrowserReadyState.Complete
              Application.DoEvents()
          End While
  
  WbBrowser.Document.GetElementById("user_login").SetAttribute("Value", "username")
  WbBrowser.Document.GetElementById("user_pass").SetAttribute("Value", "password")
  WbBrowser.Document.Forms("loginform").InvokeMember("submit")
  </code></pre>
  
  <p>This works fine. On successful login I have to navigate to another page. This will happen only if the login is correct. The issue here is as son as the login page is loaded the readystate of webbrowser control becomes complete and even before the I login to website the next line of code gets executed and results in an error as I am not logged in.</p>
  
  <pre><code>WbBrowser.Navigate("http://www.foo.com/page2.php")
  </code></pre>
  
  <p>How can I make my application wait for the login to be complete and then execute the above line of code. Any ideas?</p>