|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Random Numbers
hi guys im fairly new to Visual Basic and just wondering how i could get random numbers from 1-9. At the moment i am only able to get random numbers from 0-9 although i dont want 0s.
I have this code at the moment and im sure there is some way that i can change the 9 in the code below to get random numbers from 1-9 Randomize num1 = Int(Rnd * 9) num2 = Int(Rnd * 9) txtNum1 = num1 txtNum2 = num2 Thanks in advance. Jason Sayers |
|
#2
|
||||
|
||||
|
Example:
Code:
Dim intUpperLimit As Integer Dim intLowerLimit As Integer Dim intRandomNumber As Integer intUpperLimit = 9 intLowerLimit = 1 intRandomNumber = Int((intUpperLimit - intLowerLimit + 1) * Rnd() + intLowerLimit) |
|
#3
|
|||
|
|||
|
Thanks
Thanks for your reply.
![]() |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Random Numbers |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|