Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

msgBox

Status
Not open for further replies.

Goodloe

Programmer
Sep 4, 2001
25
US
In Visual Basic 6 I have created several forms.
I also created a Password form. The problem I'm having
with the password form is this.

I want the password form to display a message box stating
that Access is Denied after the user attempted to logon 3
times using an incorrect password, and also kick the user
out.


 
Declare a static integer variable and increment it with each unsuccessful login attempt. Check it at each attempt and if it = 3, shut down your app.
 
Thanks for responding, I've done pretty much every thing you suggested, even before sending you the message on yesterday.

For some reason I still can't get it to work. I believe
I have the Variables, Loops, and all the other code contained in the program. However, something is still going wrong.

When I keyin an incorrect password multples of times, it
still doesn't kick the user out after the third attempt.

If you can, can you send me some type of sample code to go
by in order to solve my problem? THANKS
 
Hi,

what abount something like
---------------------------------------------------------
Option Explicit
Dim CountLogins As Byte
Private Sub Command1_Click()
If Text1.Text = "ThePassword" Then
MsgBox "Welcome"
Exit Sub 'load a new form here...
End If
CountLogins = CountLogins + 1
If CountLogins = 3 Then MsgBox "Bye, bye": End
End Sub

Private Sub Form_Load()
CountLogins = 0
End Sub
-------------------------------------------------------
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
To expand on what sunaj recommended, you shouldn't use the End statement if you have forms in memory because they won't be unloaded. What I do instead is Unload the form, and in that form's Unload event I use this code to unload any other forms that may be in memory:

Form_Unload(Cancel As Integer)
For a = Forms.Count - 1 To 0 Step -1
Unload Forms(a)
Next a
End Sub

Good luck!

~Mike
Now and then it's good to pause in our
pursuit of happiness and just be happy.

- Guillaume Apollinaire
 
Thank you very much, that worked just fine
God Bless You!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top