: |
seriously? Timers are designed to execute code every XX amount of time (ie. to 'loop' as you called it)....if you want something to only run once, more than likely it shouldn't be on timer. WebBrowser has an event (u know?), I can't remember the name, but something like OnPageLoaded() which gets called after the page is loaded (and fully displayed?)..you should be checking for the web text here, not in a timer.
-the real Problem is MsgBox() doesn't return (
the next line of code can't execute until it returns) until a button is clicked -- so..set Timer.Enabled = false BEFORE calling messagebox, else it never gets executed (well, until a user presses a button, however long that might take).
If you insist on using a timer, you could create a global variable (at the top of the form class..or declare as static in the function) which indicates if the messagebox has already been shown (combined with an If() statement...only show the msgbox() if it hasn't been shown yet - duh).
Code:
Private haveIShownTheMessageBox As Boolean = False
now, in the timer's code, we will set 'haveIShownTheMessageBox' to True, and call MsgBox(). Add one more change to only show the messageBox if we haven't already done so.
Code:
Timer_()
....
If haveIShownTheMessageBox = False Then
'we haven't shown the msgbox yet..
haveIshownTheMessageBox = True '' will be true when next line of code executes
MsgBox(*****)
End If
End Sub
^^if you do create a global variable like that, at some point you'll probably want to reset 'haveIShownTheMessageBox' to false, so the messagebox can be shown again (for successive failed login attempts?), just saying. -- This would be handled much better in WebBrowser_PageLoaded().