PDA

Click to See Complete Forum and Search --> : check readystate twice


hmcheung
Oct 2nd, 2000, 01:04 PM
I've got the following code. there are two Do Until... Loop in it. Is it illegal to have two of them? coz it's ok when I have only one of them my program hangs when I have two.


Private Sub Command1_Click()
Webbrowser1.Navigate "http://www.abc.com./hello.asp"
Do Until Webbrowser1.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop

SendKeys "{tab 8}"
SendKeys "andy" 'input the search string to the text box
SendKeys "{enter}" 'this "enter" submit the form and brings up another asp

Do Until Webbrowser1.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
Web1.SetFocus
End Sub

Oct 2nd, 2000, 01:15 PM
Why would it be illegal? If it works, than use it.

You could have a DoEvents there which will also wait until the site has loaded completely before moving on to the next code.

Private Sub Command1_Click()
Webbrowser1.Navigate "http://www.abc.com./hello.asp"
DoEvents
SendKeys "{tab 8}"
SendKeys "andy" 'input the search string to the text box
SendKeys "{enter}" 'this "enter" submit the form and brings up another asp

Do Until Webbrowser1.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
Web1.SetFocus
End Sub