Looping Message Box for Login System

Posts 1–10 of 10 · Page 1 of 1
Looping Message Box for Login System
Basically, I'm working on a Login System which will grab a key phrase on a web page and display a message according to what message was retrieved. I've used a Timer to display my Message Box but it keeps displaying (looping) until you click OK for one of the dialogs.

Here's an image of my debug and code:

How to fix:

Place the msgbox inside of a timer, then link the action that calls the msgbox. Example:

(Button code)

if textbox1.text = "" then
timer1.start
timer1.stop

(Timer code)
msgbox("Message here.")

Glad to help!
Quote Originally Posted by NetherWorker View Post
How to fix:

Place the msgbox inside of a timer, then link the action that calls the msgbox. Example:

(Button code)

if textbox1.text = "" then
timer1.start
timer1.stop

(Timer code)
msgbox("Message here.")

Glad to help!
Really? (...)


Quote Originally Posted by abuckau907 View Post
: |

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().

 
edit @ Nether




wtf : /

I think the event's name is DocumentCompleted or something like that.

@OP, I just noticed this is to login to MPGH. I posted some info a while ago that is definitely usefull.

When you login in MPGH, your browser sends a http request to the server, here's an example of it:
Code:
POST http://www.mpgh.net/forum/login.php?do=login HTTP/1.1
Host: www.mpgh.net
Connection: keep-alive
Content-Length: 255
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: http://www.mpgh.net
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: http://www.mpgh.net/forum/login.php?do=login
Accept-Encoding: gzip,deflate,sdch
Data: vb_login_username=THIS+IS+MY+USERNAME&vb_login_password=THIS+IS+MY+PASSWORD&vb_login_password_hint=Password&s=&do=login&vb_login_md5password=&vb_login_md5password_utf=
What you can do however is "mimic" this request in .NET, read the response from the server and see if the credentials are valid or not.
Quote Originally Posted by NetherWorker View Post
How to fix:

Place the msgbox inside of a timer, then link the action that calls the msgbox. Example:

(Button code)

if textbox1.text = "" then
timer1.start
timer1.stop

(Timer code)
msgbox("Message here.")

Glad to help!
wtf lol...
Quote Originally Posted by TonyMane123 View Post
wtf lol...
What? I gave a solution.
Quote Originally Posted by NetherWorker View Post
What? I gave a solution.
That's not going to work with everyone's code, almost no ones code, what if we need that timer enabled durp. I'm sure we all know its the timer causing it.
: |

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().

 
edit @ Nether


timer1.start
timer1.stop
wtf : /

@kevi3434 all you have to do is put the msgbox UNDER the LoginTimer.stop(), it will still continue to read the timer code one time even if you stop it in the beginning. Then it will only show one msgbox and the timer will stop.
Thanks for the help.
Posts 1–10 of 10 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us