-
Hi! Folks,
As I am new to VbEnterprize I would be greatful for some help with the following:
Password.
Private Sub cmdEnter_Click()
Dim password As String
password = "123"
If txtPassword.Text = password Then
frmServices.Show
End If
If txtPassword.Text <> password Then
MsgBox ("Wrong Password. Please Try again"), vbRetryCancel
End If
txtPassword.Text = ""
End Sub
I would like password as Integer and not string so I can use numbers only in the password.
Enter:
cmdEnter_Click()
What code do I need to use to enter the password using the return Key also.
Many thanks.
Bill
-
Code:
Private Sub cmdEnter_Click()
Dim password As Integer
password = 123
If Val(txtPassword.Text) = password Then
frmServices.Show
ElseIf txtPassword.Text <> password Then
MsgBox ("Wrong Password. Please Try again"), vbRetryCancel
End If
txtPassword.Text = ""
End Sub
Private Sub txtPassword_KeyPress(KeyAscii AS Integer)
If Not IsNumeric(Chr(KeyAscii)) Then
KeyAscii = 0
End If
End Sub
As for the return key, set the Default property of cmdEnter to True and it will work...
-
Password help
crptcblade,
Many Thanks.
Bill
-
-
Password help
crptcblade,
Sorry to be a pain,
I wrote the code and It worked with the password 123
when anyother key is entered as a,b,c,d etc I get the following error.
ElseIf txtPassword.Text <> password Then
Cheers
Bill
-
Code:
Private Sub txtPassword_KeyPress(KeyAscii AS Integer)
If Not IsNumeric(Chr(KeyAscii)) Then
KeyAscii = 0
End If
End Sub
this code shouldn't allow you to put in anything but numbers, but try changing :
ElseIf txtPassword.Text <> password Then
to :
ElseIf Val(txtPassword.Text) <> password Then
or just plain "Else"
-
this will stop it from haveing an error
Code:
Private Sub cmdEnter_Click()
If CInt(Val( _
txtPassword.Text)) = 123 Then _
frmServices.Show
Else
MsgBox ("Wrong Password. Please Try again"), vbRetryCancel
End If
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift _
As Integer)
If keycode= 13 Then debug.Print _
"ENTER"'this is to check for enter
End Sub''cmdEnter_Click()
-
Password help