skiphooper
Registered User.
- Local time
- Yesterday, 20:03
- Joined
- Nov 29, 2000
- Messages
- 76
HI Everyone,
I have a small form that displays some of my users codes and options.
I added a command button which calls a function called testpassword.
Testpassword takes the first Initial of First name and First Initial of last name, and then add to that
a 4 position alpha numeric code to make a 6 position password.
If the last 4 positions are all alpha I then call the function again, so at least 1 of the 4
positions are numeric.
I have steped through the code and the function is called again, but still there are times
when I still get an all alpha password.
I am checking the password at the end of the loop in the function.
Can someone tell me what I am doing wrong.
Here is the function.
' ********************************************************************
Public Function TestPassword(Optional iMaxLength As Integer = 4, Optional iMinLength As Integer = 4) As String
Dim iLength As Integer
Dim iCharacter As Integer
Dim iLoop As Integer
Dim strPassword As String
Dim NewChar As String
Randomize (Time)
iLength = (Rnd * (iMaxLength - iMinLength) + iMinLength)
strPassword = ""
strPassword = UCase(Left(Forms!FORM2!txtloginname, 2))
For iLoop = 1 To iLength
Randomize (Time)
iCharacter = Int((36 * Rnd) + 1)
NewChar = Choose(iCharacter, "A", "B", "0", "C", "D", "1", "E", "F", "2", _
"G", "H", "3", "I", "J", "4", "K", "L", "5", _
"M", "N", "6", "O", "P", "7", "Q", "R", "8", _
"S", "T", "9", "U", "V", "W", "X", "Y", "Z")
strPassword = strPassword & NewChar
Next iLoop
If Not IsNumeric(Mid(strPassword, 3, 1)) And _
Not IsNumeric(Mid(strPassword, 4, 1)) And _
Not IsNumeric(Mid(strPassword, 5, 1)) And _
Not IsNumeric(Right(strPassword, 1)) Then
TestPassword
End If
TestPassword = strPassword
Forms!FORM2!Password.Caption = TestPassword
End Function
' ********************************************************************
Thanks in Advance
Skip Hooper
I have a small form that displays some of my users codes and options.
I added a command button which calls a function called testpassword.
Testpassword takes the first Initial of First name and First Initial of last name, and then add to that
a 4 position alpha numeric code to make a 6 position password.
If the last 4 positions are all alpha I then call the function again, so at least 1 of the 4
positions are numeric.
I have steped through the code and the function is called again, but still there are times
when I still get an all alpha password.
I am checking the password at the end of the loop in the function.
Can someone tell me what I am doing wrong.
Here is the function.
' ********************************************************************
Public Function TestPassword(Optional iMaxLength As Integer = 4, Optional iMinLength As Integer = 4) As String
Dim iLength As Integer
Dim iCharacter As Integer
Dim iLoop As Integer
Dim strPassword As String
Dim NewChar As String
Randomize (Time)
iLength = (Rnd * (iMaxLength - iMinLength) + iMinLength)
strPassword = ""
strPassword = UCase(Left(Forms!FORM2!txtloginname, 2))
For iLoop = 1 To iLength
Randomize (Time)
iCharacter = Int((36 * Rnd) + 1)
NewChar = Choose(iCharacter, "A", "B", "0", "C", "D", "1", "E", "F", "2", _
"G", "H", "3", "I", "J", "4", "K", "L", "5", _
"M", "N", "6", "O", "P", "7", "Q", "R", "8", _
"S", "T", "9", "U", "V", "W", "X", "Y", "Z")
strPassword = strPassword & NewChar
Next iLoop
If Not IsNumeric(Mid(strPassword, 3, 1)) And _
Not IsNumeric(Mid(strPassword, 4, 1)) And _
Not IsNumeric(Mid(strPassword, 5, 1)) And _
Not IsNumeric(Right(strPassword, 1)) Then
TestPassword
End If
TestPassword = strPassword
Forms!FORM2!Password.Caption = TestPassword
End Function
' ********************************************************************
Thanks in Advance
Skip Hooper