|
-
Mar 11th, 2001, 05:07 PM
#1
Thread Starter
Junior Member
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
-
Mar 11th, 2001, 05:12 PM
#2
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...
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Mar 11th, 2001, 05:22 PM
#3
Thread Starter
Junior Member
Password help
crptcblade,
Many Thanks.
Bill
-
Mar 11th, 2001, 05:25 PM
#4
no prob
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Mar 11th, 2001, 05:35 PM
#5
Thread Starter
Junior Member
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
-
Mar 11th, 2001, 05:41 PM
#6
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"
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Mar 11th, 2001, 05:43 PM
#7
Junior Member
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()
-
Mar 12th, 2001, 04:20 AM
#8
Thread Starter
Junior Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|