Random Value

  • Thread starter Thread starter Shapper
  • Start date Start date
S

Shapper

Hello,

I declared, in my aspx.vb code, a variable of type integer.

How can I set its value to a random value which can be only 1,2,3 or 4?

Thanks,
Miguel
 
Dim X As new Random()
Dim theNum As Short = x.Next(1,5)

Notice the max. value is set to 5, not 4. This is not very well documented,
but you will never get the max. value you specify, only values up to, but
not including the max.
 
Thank You Both.

Cheers,
Miguel

Dim X As new Random()
Dim theNum As Short = x.Next(1,5)

Notice the max. value is set to 5, not 4. This is not very well documented,
but you will never get the max. value you specify, only values up to, but
not including the max.
 

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

Back
Top