در این پست جهت سهولت کاربران که نیاز به تولید اطلاعات تصادفی (اعداد و حروف) کد ذیل قرار داده شده است :
بوسیله کلیدهای Alt + F11 وارد محیط ماکرو شده و کد ذیل را وارد نمائید :
Public Function RL(Cnt1 As Integer, Cnt2 As Integer, MySet As Integer)
Dim Rand As String
Dim i As Integer, RndNo As Integer, XSet As Integer
Dim MyCase As Integer
Application.Volatile
Select Case MySet
Case Is = "1" 'Upper case
MyCase = 65: XSet = 26
Case Is = "2" 'Lower Case
MyCase = 97: XSet = 26
Case Is = "3" 'Leading Capital
MyCase = 97: XSet = 26
Case Is = "4" 'Text digits
MyCase = 48: XSet = 10
Case Is = "5" 'Numeric digits
MyCase = 48: XSet = 10
End Select
If MySet = 3 Then 'Set leading character of "Name"
i = i + 1
Randomize
Rand = Rand & Chr(Int((26) * Rnd + 65))
End If
'Set random length of string
RndNo = Int((Cnt2 + 1 - Cnt1) * Rnd + Cnt1)
Do
i = i + 1
Randomize
Rand = Rand & Chr(Int((XSet) * Rnd + MyCase))
Loop Until i = RndNo
RL = Rand
'Convert string to number
If MySet = 5 Then RL = RL * 1
End Function
ورود به سایت