Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Random number generator
Author:
Adam Riddick
Website:
http://www.BrutalInsanity.co.uk
Submitted:
9/20/2008
Version:
VB 2005
Compatibility:
VB 2005, VB 2008
Category:
Mathematics
Views:
43768
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
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement