random number

  • Thread starter Thread starter Bill H.
  • Start date Start date
B

Bill H.

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

Thx
 
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.
 
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
 
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
 
interesting... I also had the editor insert that "#" for me, yet when I had
only 9 digits, the "#" was not inserted.

??

 
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.

??
 

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


Back
Top