Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get value to my form

Status
Not open for further replies.

ohmbru

Technical User
Jul 13, 2001
161
US
Can anyone explain how I get the result of the following code on my form:

Private Function RNum() As Integer

Randomize
RNum = Int((Me.UMax - Me.UMin + 1) * Rnd + Me.UMin)

End Function

Brian
 
Assuming you want the result put into a text box (in this case txtResult), and you are keying in the contents of UMax and UMin you could use something like

Private Function RNum() As Integer
If Not IsNull(UMax) And Not IsNull(UMin) Then
Randomize
RNum = Int((UMax - UMin + 1) * Rnd + UMin)
End If
End Function

Private Sub UMax_AfterUpdate()
txtResult = RNum
End Sub

Private Sub UMin_AfterUpdate()
txtResult = RNum
End Sub

There are two ways to write error-free programs; only the third one works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top