Solved

get different random number when program stop and start again

Posted on 2006-07-18
5
152 Views
Last Modified: 2010-04-30
hi,
I want to find a random number within a range (between max and min number). I use the following function like below.

c = minCol1 + Int(Rnd() * (maxCol1 - minCol1))

I found that this random number always show same number.  for example:

first time show 12
second time show 18
third time shows 36

when I stop the program. and then start the program again. the random number start from 12, 18, 36.  it seems random number always stay same order....

is there anyway to have random number not always different even I stop and restart the program. thank you!




0
Comment
Question by:rmtogether
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 17132359
Randomize
c = minCol1 + Int(Rnd() * (maxCol1 - minCol1))
0
 

Author Comment

by:rmtogether
ID: 17132406
hi, jimhorn

this is samething I use. but If you get random number like 3,9,5,3,63,5,6......and so on then you stop program.

when you run program again the random number you get would be 3,9,5,3,63,5,6 .....and so on. this is same with the first time when you start program.

Is it possible to have differece sequence of random numbers. after you restart program

thanks
0
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 17132450
In your code, type the keyword 'Randomize' immeately above your c+ line, save, run again.
0
 

Author Comment

by:rmtogether
ID: 17132519
hi, Jimhorn

yes, I put 'Randomize' , the result is different. thanks I got it
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 17132544
Thanks for the grade.  Good luck with your project.  -Jim

p.s. I built a screen saver five years ago in VB that used Rnd() to establish the direction and speed of pool balls moving across the screen.  For awhile, I couldn't figure out why each ball started in the same position, with the same direction and speed, until I added Randomize.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question