Reputation: 33
I'm new to Visual studio so.. I'm stuck.
I want to randomize between my numbers: 69, 119, 179
.
So when i press button1 it's gonna pick one of the 3 choices.
And then show it in Textbox1. Just as simple as that.
I found a randomize video on youtube that showed this code:
Dim rndnumber As Random
Dim number As Integer
rndnumber = New Random
number = rndnumber.Next(1, 1001)
TextBox1.Text = number.ToString
I thought that it was the right code for that but it wasn't.
Upvotes: 1
Views: 361
Reputation: 4742
Dim rndnumber As New Random
Dim MyArray() As Integer = {69, 119, 179}
TextBox1.Text = MyArray(rndnumber.Next(0, 3))
Upvotes: 3