|
|
#1 |
|
Frenzied Member
Join Date: Feb 07
Location: Malaysia
Posts: 1,349
![]() |
I have a problem.Actually I want to set a counter that allow the user to enter the valid password for 3 times.. if the password fail after 3 times attempt, the form 1 show.How to do that?
Code:
Set adoConn = New ADODB.Connection
Set adoRS = New ADODB.Recordset
Dim cs As String
cs = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\AdminPassword.mdb" & ";Persist Security Info=False;"
adoConn.ConnectionString = cs
adoConn.Open
If Text2.Text = "" Then
MsgBox "Sila masukkan Kata laluan Anda", vbCritical, "Kata laluan"
' MsgBox "Sila masukkan Kata laluan Anda"
Text2.Text = ""
Text2.SetFocus
Else
usrnm = Text2.Text
adoRS.Open "SELECT * FROM pass WHERE password='" & usrnm & "';", adoConn, adOpenStatic, adLockOptimistic
If adoRS.Fields("Password").Value = Text2.Text Then
pass = True
'if password valid, success
MsgBox "Anda Berjaya memasuki ruang admin" & vbCrLf & "Logged in. Username: " & usrnm & " !", vbInformation, "Selamat datang"
Form2.Show
Unload Me
Else
'if password invalid,message box ask to insert invalid password
MsgBox "Kata laluang tidah sah. Ruang ini hanya untuk admin", vbCritical, "WARNING"
'Exit Sub
Unload Me
Form1.Show
Exit Sub
End If
End If
End Sub
|
|
|
|
|
|
#2 |
|
Super Moderator
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 52,309
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: password problem
Something like
vb Code:
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. When you have received an answer to your question, please mark it as resolved using the Thread Tools menu. Before posting your question, did you look here? Got a question on Linux? Visit our Linux sister site. I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum. ![]() Creating A Wizard In VB.NET Modifications Required For VB6 Apps To Work On Vista Paging A Recordset What is wrong with using On Error Resume Next IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects! Microsoft MVP 2005/2006/2007/2008/2009 |
|
|
|
|
|
#3 |
|
Frenzied Member
Join Date: Feb 07
Location: Malaysia
Posts: 1,349
![]() |
Re: password problem
The counter value did not change. The value does not increase. It still start with 0 value.
Code:
If adoRS.Fields("Password").Value = Text2.Text Then
pass = True
'if password valid, success
MsgBox "Anda Berjaya memasuki ruang admin" & vbCrLf & "Logged in. Username: " & usrnm & " !", vbInformation, "Selamat datang"
frmmanagement.Show
Unload Me
Else
intCounter = intCounter + 1
If intCounter = 3 Then
frmMenu.Show
Unload Me
Else
'if password invalid,message box ask to insert invalid password
MsgBox "Invalid password", vbCritical, "WARNING"
Text2.Text = ""
Text2.SetFocus
End If
End If
|
|
|
|
|
|
#4 |
|
Super Moderator
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 52,309
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: password problem
If the first part of your code works (which I did not test) that would tell me the password was valid.
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. When you have received an answer to your question, please mark it as resolved using the Thread Tools menu. Before posting your question, did you look here? Got a question on Linux? Visit our Linux sister site. I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum. ![]() Creating A Wizard In VB.NET Modifications Required For VB6 Apps To Work On Vista Paging A Recordset What is wrong with using On Error Resume Next IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects! Microsoft MVP 2005/2006/2007/2008/2009 |
|
|
|
|
|
#5 |
|
Frenzied Member
Join Date: Feb 07
Location: Malaysia
Posts: 1,349
![]() |
Re: password problem
Yes. But if the password invalid, it go to the second part. at the second part, the user are allow enter the password for 3 times.After 3 attempt,If the password invalid the frmMenu will appear
Code:
intCounter = intCounter + 1
If intCounter = 3 Then
frmMenu.Show
Unload Me
Else
'if password invalid,message box ask to insert invalid password
MsgBox "Invalid password", vbCritical, "WARNING"
Text2.Text = ""
Text2.SetFocus
End If
|
|
|
|
|
|
#6 |
|
Super Moderator
Join Date: Aug 01
Location: Sterling Heights, Michigan
Posts: 52,309
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: password problem
If you are doing this all in a button click, then you are resetting the counter each time you click it. Take Dim intCounter As Integer and move it the forms declaration section and declare it as Private.
__________________
Please use [Code]your code goes in here[/Code] tags when posting code. When you have received an answer to your question, please mark it as resolved using the Thread Tools menu. Before posting your question, did you look here? Got a question on Linux? Visit our Linux sister site. I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum. ![]() Creating A Wizard In VB.NET Modifications Required For VB6 Apps To Work On Vista Paging A Recordset What is wrong with using On Error Resume Next IT professionals freelancer site. Register today to find coders, or offer your services for available freelance projects! Microsoft MVP 2005/2006/2007/2008/2009 Last edited by Hack; Apr 5th, 2007 at 02:08 PM. |
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|