#### Question

# How to make a random number generator in VB console?

I have to manage to make a console task which generate 8 random number for my school hmework but I really dont know how to do it , and i coudnt find a useful web in the net . i would be grateful if you give me where can i work out how to make it ,, or if you know any useful link .

thanks alot

I really need it

#### Answers

This may be VERY old, but VB is still BASIC so here goes:

The command RND, or in VB 'RANDOM' basically generates you a number between 0 and 1.

Therefore:

RND(1)*8+1 means

RND(1) - Generate a number between 0 and 1

*8 - Times it by 8 (this is our max or 'ceiling')

+1 - Means, keep the number equal to or above 1

Then if you do:

INT(RND(1)*8+1)

This does all of the above, but keeps the number as an integer (ie 4 instead of 3.5, or 4.5 etc)

So if you need an 8 digit random number.

INT(RND(1)*99999999+1) - should do the trick

http://www.vbexplorer.com/VBExplorer/ran…