Originally posted by DrUnKeN TiGeR
Code:
Private Sub cmd_ok_Click()
'This checks that the login name and password is correct'
If txb_login <> "DT" Then
MsgBox "Incorrect Login Name"
Else
txb_password = "" ' This is line six
txb_login.SetFocus
'If login name is correct it will continue to check the password'
If txb_password <> "AGN" Then ' This is line ten
MsgBox " Incorrect Password"
Else
txb_password = ""
txb_login.SetFocus
'When both the login name and password have been verifed it will open the next screen
GTA3Open.Show
txb_password = ""
Gta3.Hide
End If
End If
End Sub
Hey, no problem. I've quoted your code (and put it inside CODE and /CODE tags) so it's easier to refer to.
See the line I marked as "This is line six"? That line changes txb_password to "" (the empty string). However, just a few lines later (on the line I marked "This is line ten"), you perform the test "txb_password <> "AGN" ". That test will always be true. Why? Well, you just finished changing txb_password to "", and "" <> "AGN".
Here's another debugging tip: You can add either or both of these two lines anywhere inside your procedure, so you can check the values of the variables you are using. This can help you tell what values your variables really have.
Code:
' This line pops up a message with the value of the txb_login variable
MsgBox "txb_login = " & txb_login
' This line does the same for the txb_password variable
MsgBox "txb_password = " & txb_password
Good luck!