3 textboxes on the form txtLower, txtUpper, txtResult and a button called
cmdGenerate
Private Sub cmdGenerate_Click()
Randomize
If IsNumeric(Me.txtLower.VALUE) And IsNumeric(Me.txtUpper.VALUE) Then
Me.txtResult.VALUE = (Val(Me.txtUpper.VALUE) -
Val(Me.txtLower.VALUE) + 1) * Rnd + Val(Me.txtLower.VALUE)
End If
End Sub
to get an integer value
Private Sub cmdGenerate_Click()
Randomize
If IsNumeric(Me.txtLower.VALUE) And IsNumeric(Me.txtUpper.VALUE) Then
Me.txtResult.VALUE = Int((Val(Me.txtUpper.VALUE) -
Val(Me.txtLower.VALUE) + 1) * Rnd + Val(Me.txtLower.VALUE))
End If
End Sub
I don't know specificly what you are trying to achieve but the firstcode
will generate a floating point number between the lower and higher number,
the second will produce an integer value