Results 1 to 3 of 3

Thread: How can you create a random 5 digit number?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2003
    Posts
    1,269

    How can you create a random 5 digit number?

    anyone know?

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    VB Code:
    1. Public Function R5() As Long
    2.     Dim i As Integer
    3.     Dim TempStr As String
    4.    
    5.     For i = 1 To 5
    6.         TempStr = TempStr & CStr(Int(Rnd * 10))
    7.     Next
    8.    
    9.     R5 = CLng(TempStr)
    10. End Function
    11.  
    12. Private Sub Form_Click()
    13. Randomize Timer
    14. MsgBox R5
    15. End Sub


    Has someone helped you? Then you can Rate their helpful post.

  3. #3
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    the rule is like this Int(([upperbound] - [lowerbound] + 1) * Rnd + [lowerbound])

    so this sample will also do it for you

    VB Code:
    1. Private Sub Command1_Click()
    2.     Randomize
    3.     Debug.Print Int(90000 * Rnd + 10000)
    4. End Sub
    -= a peet post =-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width