random number

D

Dennis

Look up the Rnd function in help. However the biggest positive number that an
integer can be is 32767 so you won't be able to get a 10 digit number into an
integer.
 
R

RD

Whats the best way to generate a 10-digit positive integer random number?

Thx

"Best way"? <shrug>

I modified an old random generator of mine to get this:

Dim Myvalue As Double
Randomize
Myvalue = Int(Abs((9999999999# * Rnd) + 1000000000))

I don't know where that hash mark is coming from. The VBA editor put that in
there for me. Anyway, I tested it and it produces a ten digit number.

HTH,
RD
 
B

Bill H.

I did almost the same thing, using access help, to get this formula:


myvalue= Int((999999999 * Rnd) + 100000000)


(myvalue is a field in a table defined as double)

What I noticed was that one time I got a 10-digit number and another time a
9-digit number. :)

Bill
 
B

Bill H.

interesting... I also had the editor insert that "#" for me, yet when I had
only 9 digits, the "#" was not inserted.

??

 
B

Brendan Reynolds

I have some vague memory of reading something somewhere, that the # in this
context means that the number is too big for VBA to store precisely, and
that it will be approximated ... or something like that ... sorry, like I
said, just a vague memory.

--
Brendan Reynolds (MVP)

Bill H. said:
interesting... I also had the editor insert that "#" for me, yet when I
had
only 9 digits, the "#" was not inserted.

??
 
D

demashqe

Hi There,

Why Not Trying This:

Me.Text0 = 0
Me.TimerInterval = 0
Do While Me.Text0 >= 0
For i = 1 To 200 Step 1
If Me.TimerInterval > 0 Then Exit Sub
Me.Text0 = Int(Rnd(1) * 10000000000# + 1)
Call BaseTimer(50)
Next
Loo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Random Password Generation 0
How random is Rnd 12
Random Spinner 0
Adding rota 0
Number Printed in Reverse Order 5
Style Heading 2 5
Random Number of Long 7
Random numbers, letters, pictures? 6

Top