Reputation:
I have an array of strings and I would like to display 1 of the random values from the string array when the button is pressed. So when the "Vowels" button is pressed it displays 1 of the random vowels in the textbox.
Upvotes: 2
Views: 156
Reputation: 353
You can use this method on the Button.Click
event:
Public Class Form1
Dim rnd As New Random
Private Sub Button1_Click (ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
TextBox1.Text = strVowels(rnd.Next(strVowels.Length))
End Sub
End Class
(Thanks for the reminder of the limits of Random
, @StevenDoggart!)
Upvotes: 3