English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

This is extract of Command1_Click() of frmSetPass.frm to set and confirm password:

Private Sub Command1_Click()
On Error Resume Next
If Text1.Text = "" Then
MsgBox "You should enter a valid password", vbCritical, App.Title
Exit Sub
End If
If Text1.Text <> Text3.Text Then
MsgBox "Confirm does not match", vbCritical, App.Title
Text3.SetFocus
Text3.SelStart = 0
Text3.SelLength = Len(Text3.Text)
Exit Sub
End If
Open addstrap(getwinsysdir, "pfolder.uni") For Output As #1
Write #1, passconv.cvtstringtopass(LCase(Text1.Text))
Close #1
Unload Me
End Sub


Now, what should I do to stop users from giving a blank value for the password.

The encoding is done in ASCII. So, I need to fix the password limit between 3 and 9 characters consisting of only letters and numbers (case-sensitive) and no special characters.

2007-07-21 17:44:58 · 1 answers · asked by Anonymous in Computers & Internet Programming & Design

1 answers

In the Property Box, set Text1's MaxLength property to nine. Also, set its PasswordChar property to a character string: typically an asterisk

____________________________________
In the Command1_Click() event:

'Make sure that the user did not leave password blank.
'Place this code at the very top

If Text1.Text = vbNullString then
msgBox("You must enter a password.", VbOkOnly, "Enter a password.")

Exit Sub
End If

_____________________________________
In Text1_KeyPress()

'Validate numbers and characters
'Place this code at the very top

'Note, I did not use the IsNumeric() because it incorrectly considers certain strings as valid numbers.

Select Case KeyAscii

Case Is < 32 'Control keys are okay
Case 48 to 57 'It's a digit
Case Is 65 To 90 'It's an upper case letter of alphabet
Case Is 97 To 122 'It's a lower-case letter of alphabet
Case Else
KeyAscii = 0 'Eats the keystroke
Exit Sub 'No use continuing, it's not a valid character
End Select


____________________________________

2007-07-21 18:45:16 · answer #1 · answered by Einstein 5 · 2 0

fedest.com, questions and answers