Random number generator (VB.NET)
Version: VB 2005
Compatibility: VB 2005
Category: Mathematics
Grabs a random number between two designated, or user input designated numbers. VB.NET
Declarations:
In the instance i have used this, Low is a variable set by the program, not the user. High is based on user input. To allow the user to choose also the low number, just edit and follow the basis for High.
HighNum is a Textbox
Number is a label, in the program i started with this label hidden until the number is generated.
Get_random is the number generated itself. How it works speaks for itself.
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Low As Integer = 1
Dim High As Integer
High = HighNum.Text
Get_Random(Low, High)
Number.Visible = True
Beep()
End Sub
Sub Get_Random(ByVal Low As Integer, ByVal High As Integer)
Number.Text = Math.Floor((High - Low + 1) * Rnd() + Low)
End Sub
1 comments:
your background & link colour sucks..hard to read it..
Post a Comment