by john tomson (9 Submissions)
Category: Miscellaneous
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Mon 14th November 2005
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
generate password
API Declarations
commandbuttons called commandbutton1 , command1
Private Sub Command1_Click()
Text1.Text = RandomPass(z) 'The 6 is the number of password charicters
End Sub
Public Function RandomPass(ByVal ChaNum As Integer) As String
For ju = 0 To ChaNum
Dim rnn As Integer
Randomize
rnn = Int(Rnd * 2) 'Generate random number 0 or 1
If rnn = "0" Then
'Get random Charicter
Dim RandNum As Integer
Dim SetChar As String
redo:
Randomize
RandNum = Int(Rnd * 122) 'generate random ascii number
If RandNum > 64 And RandNum < 90 Or RandNum > 97 And RandNum < 122 Then
'if the numbers are in the relevent area's:
'MsgBox RandNum
SetChar = Chr$(RandNum)
randomchar = randomchar & SetChar
Else
GoTo redo 'otherwise do it again
End If
Else
'Get random number
randomchar = randomchar & Int(Rnd * 9)
End If
Next ju
RandomPass = randomchar
End Function
Private Sub CommandButton1_Click()
j$ = "Input the amount of a characters the password contains"
k$ = "password characters"
z = InputBox(j$, k$)
End Sub