|
|
|
Generate random letters with VBA macro
0
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




There are currently no comments for this snippet.