尝试使用0-9和az/AZ创建一个随机字符串,长度为x的字符,似乎无法找到一个好例子,任何想法?
Function RandomString(cb As Integer) As String Randomize Dim rgch As String rgch = "abcdefghijklmnopqrstuvwxyz" rgch = rgch & UCase(rgch) & "0123456789" Dim i As Long For i = 1 To cb RandomString = RandomString & Mid$(rgch, Int(Rnd() * Len(rgch) + 1), 1) Next End Function
请注意,内置随机数生成器不具有cryprograph安全性,因此不应使用此类函数生成密码.