G
Guest
Hello, everybody,
I would like to have an auto-generated username and password with characters
taken from a CompanyName field but without any spaces or any other
characther not included in the CompanyName field.
What I have now considers 36 random characters and the code is:
Public Function fGenRandomString(intCharCount As Integer) As String
Dim i As Integer
Dim intPos As Integer
Dim strOut As String
Dim strOne As String * 1
Dim strCharPool As String
Const strChars = "abcdefghijklmnopqrstuvwxyz1234567890"
strCharPool = strChars
strOut = ""
If Not intCharCount > Len(strChars) Then
Randomize
For i = 1 To intCharCount
intPos = Int(Len(strCharPool) * Rnd + 1)
strOne = Mid(strCharPool, intPos, 1)
strCharPool = Left(strCharPool, intPos - 1) & Mid(strCharPool,
intPos + 1)
strOut = strOut & strOne
Next
Else
strOut = "Too Long"
End If
fGenRandomString = strOut
End Function
I would like to have an auto-generated username and password with characters
taken from a CompanyName field but without any spaces or any other
characther not included in the CompanyName field.
What I have now considers 36 random characters and the code is:
Public Function fGenRandomString(intCharCount As Integer) As String
Dim i As Integer
Dim intPos As Integer
Dim strOut As String
Dim strOne As String * 1
Dim strCharPool As String
Const strChars = "abcdefghijklmnopqrstuvwxyz1234567890"
strCharPool = strChars
strOut = ""
If Not intCharCount > Len(strChars) Then
Randomize
For i = 1 To intCharCount
intPos = Int(Len(strCharPool) * Rnd + 1)
strOne = Mid(strCharPool, intPos, 1)
strCharPool = Left(strCharPool, intPos - 1) & Mid(strCharPool,
intPos + 1)
strOut = strOut & strOne
Next
Else
strOut = "Too Long"
End If
fGenRandomString = strOut
End Function