Generate random letters with VBA macro





0
Date Submitted Mon. Dec. 15th, 2008 6:57 AM
Revision 1 of 1
Beginner suin
Tags excel | Password | Random | VBA
Comments 0 comments
This is a function which generates random letters for password. Programers can use this at Microsoft Excel and so on.

Public Function pass(Optional intLength As Integer = 8, Optional boolIncUpper As Boolean = False, Optional boolIncSign As Boolean = False)

    Dim strPass As String
    Dim strLower As String
    Dim strUpper As String
    Dim strNumber As String
    Dim strSign As String
    Dim strChars As String
    Dim intMax As Integer
    Dim i As Integer
   
    strLower = "qwertyuiopasdfghjklzxcvbnm"
    strUpper = "QWERTYUIOPASDFGHJKLZXCVBNM"
    strNumber = "123456789"
    strSign = "-^@[;:],./!""#$%&'()=~|`{+*}<>?_"

    strChars = strLower & strNumber

    If boolIncUpper = True Then
   
        strChars = strChars & strUpper
   
    End If
   
    If boolIncSign = True Then
   
        strChars = strChars & strSign
       
    End If

    intMax = Len(strChars)
   
    For i = 1 To intLength
   
        strPass = Mid(strChars, Int((intMax - 1 + 1) * Rnd + 1), 1) & strPass
   
    Next i

    pass = strPass

End Function
 

Suin Yeze

Comments

There are currently no comments for this snippet.

Voting

Votes Up


Votes Down