How to make a random number generator
Use this board to post your code snippets - tips and tricks
5 posts
Page 1 of 1
1)First, add a button from the toolbox to generate the number
2)Next, add a textbox to the form
3)Last, double click on the button and enter this code
2)Next, add a textbox to the form
3)Last, double click on the button and enter this code
Code: Select all
4)That was easy, wasn't it?Dim rndnumber As Random
Dim number As Integer
rndnumber = New Random
number = rndnumber.Next(1, 1001)
TextBox1.Text = number.ToString
think ive seen this before but good snip
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that 

zachman61 wrote:think ive seen this before but good snip
Lewis-Froom wrote:Yes i have seen this before, But nice snip anyway.Yeas u 2 have probably seen that before than what most "Supposedly keygens" use in vb to randomly select one of the keys feed into the program. Nice Snip Though.
If you want to make a variable length random number you can use this:
Code: Select all
Dim times As Integer = 30
Dim r As Random = New Random()
Dim out As String = ""
For i As Integer = 0 To times - 1
Dim res As Integer = r.Next(0, 10)
out += res.ToString()
Next
TextBox1.Text = out
5 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023