sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
Sparky AKA_Sparkticus's Avatar

random numbers help needed


Question posted by: Sparky AKA_Sparkticus (Guest) on July 17th, 2005 10:19 PM


Hi I am trying to create two random numbers

LBlnum1.Caption = Int(12 * Rnd) + 1
Lblnum2.Caption = Int(12 * Rnd) + 1

This creates the numbers but they are always the same numbers.
example I get 9 & 7 then 7 & 4 then 10 & 1

is their a way to make these numbers more random ?


Sparky


2 Answers Posted
Rick Rothstein's Avatar
Rick Rothstein July 17th, 2005 10:19 PM
Guest - n/a Posts
#2: Re: random numbers help needed

> Hi I am trying to create two random numbers[color=blue]
>
> LBlnum1.Caption = Int(12 * Rnd) + 1
> Lblnum2.Caption = Int(12 * Rnd) + 1
>
> This creates the numbers but they are always the same numbers.
> example I get 9 & 7 then 7 & 4 then 10 & 1
>
> is their a way to make these numbers more random ?[/color]

Execute the Randomize statement (only one time) somewhere inside your
program before using the Rnd function. The best place to execute the
Randomize function is in the Form_Load event (or Sub Main if you start
your programs that way).

Rick - MVP

Sparky AKA_Sparkticus's Avatar
Sparky AKA_Sparkticus July 17th, 2005 10:19 PM
Guest - n/a Posts
#3: Re: random numbers help needed

Rick Rothstein wrote:[color=blue][color=green]
>> Hi I am trying to create two random numbers
>>
>> LBlnum1.Caption = Int(12 * Rnd) + 1
>> Lblnum2.Caption = Int(12 * Rnd) + 1
>>
>> This creates the numbers but they are always the same numbers.
>> example I get 9 & 7 then 7 & 4 then 10 & 1
>>
>> is their a way to make these numbers more random ?[/color]
>
> Execute the Randomize statement (only one time) somewhere inside your
> program before using the Rnd function. The best place to execute the
> Randomize function is in the Form_Load event (or Sub Main if you start
> your programs that way).
>
> Rick - MVP[/color]

Cheers worked great.....

Sparky


 
Not the answer you were looking for? Post your question . . .
196,804 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,804 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors