Results 1 to 3 of 3

Thread: [Resolved] Random number

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Location
    Belgium
    Posts
    2

    Question [Resolved] Random number

    Hi all,

    I need a function that takes a random NUMBER from 0 to 35. Something like:
    VB Code:
    1. number = random (0, 35)
    Is this possible, and does anyone now ho I can do this?
    Last edited by eXziBit; Dec 26th, 2004 at 08:38 AM. Reason: [Resolved]

  2. #2
    Fanatic Member vbasicgirl's Avatar
    Join Date
    Jan 2004
    Location
    Manchester, UK
    Posts
    1,016

    Re: Random number

    VB Code:
    1. Private Sub Form_Load()
    2.  Randomize
    3. End Sub
    4.  
    5. Private Sub Command1_Click()
    6.  Dim num As Integer
    7.  
    8.  num = Int(Rnd * 36)
    9.  
    10.  MsgBox num
    11.  
    12. End Sub
    look at the Rnd() function in msdn to see the syntax plus always put Randomize in the form load event when dealing with ramdom numbers.

    casey.

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Location
    Belgium
    Posts
    2

    Re: Random number

    Quote Originally Posted by vbasicgirl
    VB Code:
    1. Private Sub Form_Load()
    2.  Randomize
    3. End Sub
    4.  
    5. Private Sub Command1_Click()
    6.  Dim num As Integer
    7.  
    8.  num = Int(Rnd * 36)
    9.  
    10.  MsgBox num
    11.  
    12. End Sub
    look at the Rnd() function in msdn to see the syntax plus always put Randomize in the form load event when dealing with ramdom numbers.

    casey.


    VB Code:
    1. Randomize End Sub
    This gives an error


    [edit]It works without the "End Sub".[/edit]
    Last edited by eXziBit; Dec 26th, 2004 at 08:37 AM.

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