Results 1 to 10 of 10

Thread: Create random number [Resolved]

  1. #1

    Thread Starter
    Addicted Member Rogier's Avatar
    Join Date
    Jun 2004
    Location
    Netherlands
    Posts
    143

    Exclamation Create random number [Resolved]

    Hi,

    How can I create a random number in a textbox between 1 and 1000?
    Last edited by Rogier; Feb 19th, 2005 at 03:36 PM. Reason: Resolved

  2. #2
    Addicted Member Psychotic's Avatar
    Join Date
    May 2004
    Posts
    164

    Re: Create random number

    you would have to use the RND statement
    -Psychotic-

  3. #3

    Thread Starter
    Addicted Member Rogier's Avatar
    Join Date
    Jun 2004
    Location
    Netherlands
    Posts
    143

    Re: Create random number

    and that is.........?
    Can you make a code for me please?

  4. #4
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Create random number

    VB Code:
    1. form_load()
    2. randomize
    3. end sub
    4.  
    5. command1_click()
    6. rnd (1 - 1000)
    7. end sub

    i think thats right, or try 1 * 1000
    Last edited by |2eM!x; Feb 19th, 2005 at 03:33 PM.

  5. #5

    Thread Starter
    Addicted Member Rogier's Avatar
    Join Date
    Jun 2004
    Location
    Netherlands
    Posts
    143

    Re: Create random number

    ok thanks,

    Text1.Text = Rnd

    Just what I need.

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Create random number [Resolved]

    VB Code:
    1. randomize ' seed random number generator
    2. text1.text = int((rnd * 1000) + 1) ' pick random integer between 1 and 1000

    this is what you need to use.

  7. #7

    Thread Starter
    Addicted Member Rogier's Avatar
    Join Date
    Jun 2004
    Location
    Netherlands
    Posts
    143

    Re: Create random number [Resolved]

    YES!
    That's exactly what I want.
    Thanks!

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Create random number [Resolved]

    That's what I thought.

  9. #9
    Junior Member
    Join Date
    Feb 2005
    Posts
    21

    Re: Create random number [Resolved]

    yea u need INT(rnd......) to knock off the decimal places since the randomize function does 0-1 but not the whole # 1


    randomize **** is fun to play with... i wrote a program that randomizes the back color of the form every milisecond...set it do do 0 - 999999(hexicode for colors and **** thats y theirs 6)

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Create random number [Resolved]

    Quote Originally Posted by dglienna
    VB Code:
    1. randomize ' seed random number generator
    2. text1.text = int((rnd * 1000) + 1) ' pick random integer between 1 and 1000

    this is what you need to use.


    text1.text = int((rnd * 1000) + 1) ' pick random integer between 1 and

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