anyone know?
Printable View
anyone know?
VB Code:
Public Function R5() As Long Dim i As Integer Dim TempStr As String For i = 1 To 5 TempStr = TempStr & CStr(Int(Rnd * 10)) Next R5 = CLng(TempStr) End Function Private Sub Form_Click() Randomize Timer MsgBox R5 End Sub
the rule is like this Int(([upperbound] - [lowerbound] + 1) * Rnd + [lowerbound])
so this sample will also do it for you
VB Code:
Private Sub Command1_Click() Randomize Debug.Print Int(90000 * Rnd + 10000) End Sub