VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Generates a random password (numbers & characters). Number of characters is customizable.

by Masters@Work (2 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 23rd December 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Generates a random password (numbers & characters). Number of characters is customizable.

Rate Generates a random password (numbers & characters). Number of characters is customizable.



'leave the commandbutton at its default name (command1).
Private Sub Command1_Click()
Text1.Text = RandomPass("6") '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

Download this snippet    Add to My Saved Code

Generates a random password (numbers & characters). Number of characters is customizable. Comments

No comments have been posted about Generates a random password (numbers & characters). Number of characters is customizable.. Why not be the first to post a comment about Generates a random password (numbers & characters). Number of characters is customizable..

Post your comment

Subject:
Message:
0/1000 characters