thejazzman
03-29-04, 04:57 AM
I have been learning vb for the passed couple of weeks but ive come across a problem which i cant seem to work out.
I need to loop the program so when you click the login command button (cmdLogin) it checks the user number and password, if these are wrong it gives you another chance to re-enter the usernumber and password, again if these are wrong it allows you to enter you user number and password one last time, it then exits the program unless you enter the correct details.
The code i have up to now is written below. As you can see there is no loop in it.
Could you please show me how to insert the loop which is described above. Thank You.
Private Sub cmdLogin_Click()
Dim strCustomerNumber As String
Dim strPassword As String
strCustomerNumber = txtCustomerNumber
strPassword = txtPassword
If strCustomerNumber = "10001" And strPassword = "ONE" Then
LoginSuccessful = True
Me.Hide
frmWelcome.Show
ElseIf strCustomerNumber = "10002" And strPassword = "TWO" Then
LoginSuccessful = True
Me.Hide
frmWelcome.Show
ElseIf strCustomerNumber = "10003" And strPassword = "THREE" Then
LoginSuccessful = True
Me.Hide
frmWelcome.Show
ElseIf strCustomerNumber = "10004" And strPassword = "FOUR" Then
LoginSuccessful = True
Me.Hide
frmWelcome.Show
ElseIf strCustomerNumber = "10005" And strPassword = "FIVE" Then
LoginSuccessful = True
Me.Hide
frmWelcome.Show
Else
LoginSuccessful = False
MsgBox "Invalid User Number or Password, try again!", vbInformation, "Login"
End If
End Sub
I need to loop the program so when you click the login command button (cmdLogin) it checks the user number and password, if these are wrong it gives you another chance to re-enter the usernumber and password, again if these are wrong it allows you to enter you user number and password one last time, it then exits the program unless you enter the correct details.
The code i have up to now is written below. As you can see there is no loop in it.
Could you please show me how to insert the loop which is described above. Thank You.
Private Sub cmdLogin_Click()
Dim strCustomerNumber As String
Dim strPassword As String
strCustomerNumber = txtCustomerNumber
strPassword = txtPassword
If strCustomerNumber = "10001" And strPassword = "ONE" Then
LoginSuccessful = True
Me.Hide
frmWelcome.Show
ElseIf strCustomerNumber = "10002" And strPassword = "TWO" Then
LoginSuccessful = True
Me.Hide
frmWelcome.Show
ElseIf strCustomerNumber = "10003" And strPassword = "THREE" Then
LoginSuccessful = True
Me.Hide
frmWelcome.Show
ElseIf strCustomerNumber = "10004" And strPassword = "FOUR" Then
LoginSuccessful = True
Me.Hide
frmWelcome.Show
ElseIf strCustomerNumber = "10005" And strPassword = "FIVE" Then
LoginSuccessful = True
Me.Hide
frmWelcome.Show
Else
LoginSuccessful = False
MsgBox "Invalid User Number or Password, try again!", vbInformation, "Login"
End If
End Sub