Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

VB Question

  • 28-01-2002 8:12pm
    #1
    Registered Users, Registered Users 2 Posts: 1,182 ✭✭✭


    Just wondering if any of ye code guru's could tell me how to generate a random number between 1 and 100 in VB!?
    Cheers,

    Beef. :)


Comments

  • Registered Users, Registered Users 2 Posts: 707 ✭✭✭d4r3n


    Randomize
    MsgBox Int((High - Low + 1) * Rnd) + Low


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Randomize : MsgBox Int(100 * Rnd) + 1


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Randomize

    Shouldn't that be Randomize Timer ? Wouldn't the radomize reset the seed with the same value all the time? or did they change that for VB?


  • Registered Users, Registered Users 2 Posts: 16,414 ✭✭✭✭Trojan


    Originally posted by Hobbes
    Randomize

    Shouldn't that be Randomize Timer ? Wouldn't the radomize reset the seed with the same value all the time? or did they change that for VB?

    Maybe that's in an older version. Just Randomize should work fine with VB5 or 6.


    Rand(range start, range end) should do fine.
    dim x%, y%
    
    Randomize
    
    x = Rnd
    y = Rand(1, 100)
    

    Al.


  • Registered Users, Registered Users 2 Posts: 1,182 ✭✭✭Beef


    Sher it worked fine! Cheers!(Just Randomize works btw)
    :D


  • Advertisement
  • Closed Accounts Posts: 9,314 ✭✭✭Talliesin


    Shouldn't that be Randomize Timer ? Wouldn't the radomize reset the seed with the same value all the time? or did they change that for VB?

    Randomize Timer is still allowed for backwards compatibility, but Randomize with no argument is taken to be equivalent.


Advertisement