Function randnumber()
'随机加字母大小写,加的位数不一样,2-6位
Dim temprnd, temprnd2 As String
Dim temprndnum As Long
temprnd2 = ""
temprndnum = Int((4 * Rnd) + 2) '随机数
For i = 1 To temprndnum
If Int(Rnd() * 2) = 0 Then
temprnd = Chr(Int(Rnd() * 26) + 65) '大写英文字母
Else
temprnd = Chr(Int(Rnd() * 26) + 97) '小写英文字母
End If
randnumber = randnumber + temprnd
Next i
End Function
转载于:https://www.cnblogs.com/bignine/p/10114409.html
本文介绍了一个使用VBA编写的随机字母生成器函数。该函数可以生成2到6位长度的随机字符串,包含大小写英文字母。通过随机选择大写或小写字母并拼接成指定长度的字符串,实现随机性的增加。
1676

被折叠的 条评论
为什么被折叠?



