Randam No...... KRISH

K

KRISH

Hi everybody,
I am developing a hostel software. I want to allot a hostel out of 7 to some
600 students 100 in each hostel. My table fields are [ID], [Name], [Hostel
Code]. I want to pick a student randamly and allot hostel. How to do this.
Please Help.
Thanks in advance.
Krish
 
C

Chris Burnette

Here is an example of a random number generator. This program generates a
random 6 digit number, in which each digit is between 1 and 9. The number is
then outputted to a text box called txtRand. You should fairly easily be
able to modify this for your purposes.

Private Sub btnRand_Click()

Dim MyValue(6) As Integer
Dim OurValue As String
Dim i As Integer

i = 1

For i = 1 To 6 'loops through the sequence 6 times
Randomize ' Initialize random-number generator.
MyValue(i) = Int((9 * Rnd) + 1) ' Generate random value between 1 and
9.
Next i

OurValue = MyValue(1) & MyValue(2) & MyValue(3) & MyValue(4) & MyValue(5) &
MyValue(6) 'assigns each digit to a text string

DoCmd.GoToControl "txtRand"
txtRand.Text = OurValue 'outputs text string to text box
End Sub

-Chris
 

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


Top