Needs some very simple VB help... Generating Random Numbers
+ Reply to Thread
Results 1 to 5 of 5

Thread: Needs some very simple VB help... Generating Random Numbers

  1. Top | #1
    Fresh Member
    Join Date
    May 2002
    Posts
    2
    Threads
    0

    Needs some very simple VB help... Generating Random Numbers

    Im beng rather a spack here but i cant seem to get this program im doing to generate random numbers.

    I want it do generate random numbers between 2 limits (which are loaded from an outside file but i;ve got that sorted)

    Basically i want it to be like this

    Number = Random between Limit1 & Limit2

    But its always coming up with a value of 0 and im not sure why.

    Help anyone?

  2. Top | #2
    Junior Onion
    Join Date
    May 2003
    Location
    London, UK
    Posts
    2,277
    Threads
    104

    Re: Needs some very simple VB help... Generating Random Numbers

    Also i cant seem to remeber how to use modules at all really. I've got a variable defined in a module, i want to be able to assign it a value on one form then use that value on another form.... cant remember for the life of me how to do it either though


    PLEASE PLEASE HELP

  3. Top | #3
    Veteran Onion
    Join Date
    Apr 2001
    Location
    Closer than you think
    Posts
    4,365
    Threads
    24

    Re: Needs some very simple VB help... Generating Random Numbers

    Quote Originally Posted by The_Spoon
    Also i cant seem to remeber how to use modules at all really. I've got a variable defined in a module, i want to be able to assign it a value on one form then use that value on another form.... cant remember for the life of me how to do it either though


    PLEASE PLEASE HELP
    I'd like to know this too! I can assign sub procedures on one form and use them fine but i want to know how to use them on another form without making the sub procedure again.

  4. Top | #4
    Junior Proxycon Emperor
    Join Date
    May 2001
    Location
    UK .
    Posts
    12,345
    Threads
    68

    Re: Needs some very simple VB help... Generating Random Numbers

    Quote Originally Posted by Mr_Spoon
    Im beng rather a spack here but i cant seem to get this program im doing to generate random numbers.

    I want it do generate random numbers between 2 limits (which are loaded from an outside file but i;ve got that sorted)

    Basically i want it to be like this

    Number = Random between Limit1 & Limit2

    But its always coming up with a value of 0 and im not sure why.

    Help anyone?
    Quote Originally Posted by Mr_Spoon
    [FONT=arial][SIZE=2][FONT=Arial, Helvetica][SIZE=2][FONT=Courier New][SIZE=3]Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

    [/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][FONT=arial][SIZE=2][FONT=Arial, Helvetica][SIZE=2]Here, upperbound is the highest number in the range, and lowerbound is the lowest number in the range.[/SIZE][/FONT][/SIZE][/FONT]
    [FONT=arial][SIZE=2][FONT=Arial, Helvetica][SIZE=2][FONT=Courier New][SIZE=3]
    [/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT]
    http://www.powerasp.com/content/new/...ference-59.htm

    thats vbscript - see if it works in vbasic
    [FONT=arial][SIZE=2][FONT=Arial, Helvetica][SIZE=2][FONT=Courier New][SIZE=3]

    [/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT]

  5. Top | #5
    Junior Proxycon Emperor
    Join Date
    May 2001
    Location
    UK .
    Posts
    12,345
    Threads
    68

    Re: Needs some very simple VB help... Generating Random Numbers

    Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

    Here, upperbound is the highest number in the range, and lowerbound is the lowest number in the range.

    http://www.powerasp.com/content/new/...ference-59.htm

    thats vbscript - see if it works in vbasic
    Last edited by blackstar; 04-28-2006 at 08:57 AM.

+ Reply to Thread

Posting Permissions

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