LotusScript/Visual Basic Random Number Generator

Author: Tripp W Black

Created: 11/13/2000 at 05:48 PM

 

Category:
Notes Developer Tips
LotusScript

Sub Click(Source As Button)
Dim x As Long, y As Long, z As Long, tempnum As Long
Dim flag As Integer
Dim i As Integer
Dim Num_list As String


x = Inputbox("Enter starting Random Number", "Random Number Generation", 1)
y = Inputbox("Enter ending Random Number", "Random Number Generation", 100)
z = Inputbox("How many random numbers would" & "you like to generate (<20)?" _
, "Random Number Generation", 20)
If z = 0 Then Exit Sub
If z > 20 Then z = 20
If z > y - x + 1 Then
Msgbox "You specified more numbers to return than " _
& "are possible in the range!"
Exit Sub
End If
Randomize
Num_list = Int((y - x + 1) * Rnd + x) & ", "


For i = 2 To z
Do
flag = False
Randomize
tempnum = Int((y - x + 1) * Rnd + x)
If (Instr(Num_list, tempnum)) Then
flag = True
End If
Loop Until Not flag
Num_list = Num_list & tempnum & ", "
Next
Msgbox (Num_list)
End Sub


previous page