Random Numbers

Can some one please help me with this, Im using access 2007: I have a form with a button which must generate random numbers and put the number in a textbox. I have this code for my button:

Dim RandNum
Randomize
RandNum=Int((200-2+1)*Rnd+2)
Me.Item_Code=RandNum


I want the button to generate numbers between 2 and 200, and return those numbers in the Item Code textbox in the form. I also want the random numbers not to be repeated.

Thanx.
Vuyo.

Comments

  • Hey
    Try using
    [code]
    Imports System.Random

    Dim RandomNumber As Integer
    'generate the random numbers between 2 and 200
    RandomNumber = RandomClass.Next(2, 200)
    [/code]

    and a array list to store the values. Then compare the newly generated number to the values stored within the array list. If there they are the same then generate a new number and the process starts all over again.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion