- Home
·
- Miscellaneous
·
- Random no generator.No number is repeated once it has been generated
Random no generator.No number is repeated once it has been generated
Random no generator.No number is repeated once it has been generated
Rate Random no generator.No number is repeated once it has been generated
(1(1 Vote))
Public Function Rand(Initial As Integer, Final As Integer) As Integer
Dim n As Integer
Static par As Integer
Dim i As Integer
Static arr(100) As Integer
Randomize
Again: n = Rnd * Final
For i = Initial To Final
If n = arr(i) Then GoTo Again
Next i
arr(par) = n
par = par + 1
Rand = n
End Function
Private Sub Command1_Click()
Dim p As Integer
p = Rand(0, 10) 'the range is 0 to 10.you can supply your
'range also
'Every time you click the command button the "function
'rand will generate a new random no within the range
'the limitation of the function is once it has generated
'all the nos within the range then it will not respond
'to another click as now it will not have any nos to generate
Text1.Text = p
End Sub
Random no generator.No number is repeated once it has been generated Comments
No comments yet — be the first to post one!
Post a Comment