PDA

View Full Version : Random Number


MikeFairbrother
04-19-04, 10:53 AM
Hi, Im wondering if anyone can help me, i have to text boxes or label boxes and i want then to display a random number - i also need a refresh button so each time you click that, it display a random number again, can anyone help?

MikeFairbrother
04-20-04, 03:44 PM
Hi, Im wondering if anyone can help me, i have to text boxes or label boxes and i want then to display a random number - i also need a refresh button so each time you click that, it display a random number again, can anyone help?

sorry for double posting, but please can someone help me

Nerddette
04-22-04, 08:27 PM
This may not answer your question, but you can create an autonumber field with the increment value set to random. This would actually store the value in the record. I guess to generate another number you would have to create a new record - don't know if that solves the problem? The other option is to use the =RANDOM() function provided in Excel (see other post 'Generate a List of Numbers') and then bring the numbers from Excel?

I could probably fiddle around with this a bit more if you want and see whether the =RANDOM() function can be generated in VBA. Just let me know if that would help.

Nerddette

kebo
04-27-04, 06:35 PM
This may not answer your question, but you can create an autonumber field with the increment value set to random. This would actually store the value in the record. I guess to generate another number you would have to create a new record - don't know if that solves the problem? The other option is to use the =RANDOM() function provided in Excel (see other post 'Generate a List of Numbers') and then bring the numbers from Excel?

I could probably fiddle around with this a bit more if you want and see whether the =RANDOM() function can be generated in VBA. Just let me know if that would help.

Nerddette

with a button and a textbox on a form, try the following code:

Private Sub Command1_Click()
Randomize
Text1.Text = Int((500 * Rnd) + 1) ' Generate random value between 1 and 500.
End Sub

kevin

hubo
06-22-04, 01:36 PM
sorry for double posting, but please can someone help me

there is a function

Rnd

use this in your code



random_number = rnd
random = random_number * the maximum value


than the variable random is the random number