Page 1 of 1

How to make a random number generator

Posted: Fri Jul 23, 2010 10:09 am
by flashsight
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
Code: Select all
Dim rndnumber As Random
        Dim number As Integer
        rndnumber = New Random
        number = rndnumber.Next(1, 1001)
        TextBox1.Text = number.ToString
4)That was easy, wasn't it?

Re: How to make a random number generator

Posted: Sat Jul 24, 2010 12:57 am
by zachman61
think ive seen this before but good snip

Re: How to make a random number generator

Posted: Sat Jul 24, 2010 11:31 am
by Lewis
Yes i have seen this before, But nice snip anyway.

Re: How to make a random number generator

Posted: Wed Jul 28, 2010 9:38 am
by un kn0 wn
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.

Re: How to make a random number generator

Posted: Wed Jul 28, 2010 10:39 am
by mandai
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