?
Solved

get different random number when program stop and start again

Posted on 2006-07-18
5
Medium Priority
?
155 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 66

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 66

Accepted Solution

by:
Jim Horn earned 2000 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 66

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

770 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