Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

get different random number when program stop and start again

Posted on 2006-07-18
5
Medium Priority
?
156 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

598 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