|
-
Jul 26th, 2011, 06:41 PM
#1
Thread Starter
Banned
generate random number from range
Code:
Dim random As New Random()
random.Next(65, 91) ' random.Next(min, max) the range is min to max -1
EDIT for akhileshbc : place this code in an event, the Dim random As New Random() can also be placed as a global variable (in a class and not in an event )
the code returns a random number between a minimum and a maximun in the example above a number between 65 and 91 will be returned
you can also do stuff like : (instead of the line random.Next(65, 91))
label1.text = random.Next(65, 91) ' the label will display a random number in the range 65 - 91
or
textbox1.text &= random.Next(65, 91) ' concates a random number to the textbox (added from the tool box to the form)
or
textbox1.text &= chr(random.Next(65, 91)) ' concates a random char (a - z) to the textbox
Last edited by moti barski; Jul 27th, 2011 at 03:25 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|