i have 20 numbers that i need to randomize to 20 variables.... any ideas

example numbers would be:

1
5
10
20
50
100
200
500
1000

well depends, does each number have to be different? if they dont you can do this

dim numbers(19) as integer
numbers(0) = int((rnd*20)+1)

and do that same one for numbers(0) for all of them through 19, just replace the 0 with the next number, i think that code is right,... it might be a little off so if someone else can double check, then ill know for future reference.

if each one has to be different then it would be a big if statement rerandomizing it each time

p.s. my way would probably be harder than someone else's so if you want to try mine, go ahead. although the randomize statement(rnd) doesnt seem to be so random, it will be the same order everytime you start up the program, so you might want to wait for someone else to answer

try this following code :

Public Function MakeNumRand() As String
        Dim NumRand As New Random
        Dim temp As String
        temp = NumRand.Next(1, 20)
        Return temp
    End Function

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = MakeNumRand()
    End Sub

code above generate with pressing button, you can change it to generate for each variable

try this following code :
code above generate with pressing button, you can change it to generate for each variable

Does this piece of code generate DIFFERENT numbers for each variable?(i need different number for each label...)
can you show an example how to generate for each variable? use variable1, variable2 and variable3 as variable names so that i can understand....

thank you

This article has been dead for over six months. Start a new discussion instead.