Hi
can anyone teach me how to use visual basic to make a random number generate between 1 to 10
than
example:
if the generate number is 1 it will display "abc" on the textbox
if the generate number is 2 it will display "cba" on the textbox
Pls help me thank!
Loading
SolitairePosted Dec 5, 2006, 7:34 PM
intRandom = rnd.Next(0, 10)
will generate a random number between 0 and 9. The second argument after Next must be 1 more than the upper limit of the range.
For the above example, you should use:
intRandom = rnd.Next(1, 11)
Scott LyslePosted Nov 24, 2006, 3:33 AM
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim rnd As New Random()
Dim intRandom As Integer
intRandom = rnd.Next(0, 10) Select Case intRandom
Case 1
TextBox1.Text = "ABC"
Case 2
TextBox1.Text = "DEF"
Case 3
TextBox1.Text = "GHI"
Case 4
TextBox1.Text = "JKL"
Case 5
TextBox1.Text = "MNO"
Case 6
TextBox1.Text = "PQR"
Case 7
TextBox1.Text = "STU"
Case 8
TextBox1.Text = "VXY"
Case 9
TextBox1.Text = "ZAB"
Case 10
TextBox1.Text = "ZAC"
Case Else
TextBox1.Text = "AAA"
End Select
End Sub
Desmond TanPosted Nov 21, 2006, 10:48 AM
if can send me a sample pls... [email protected]...
Scott LyslePosted Nov 16, 2006, 10:25 PM
Dim
rnd As New Random() Dim intRandom As IntegerintRandom = rnd.Next(0, 10)
MessageBox.Show(
"Random Number between 0 and 10: " & intRandom.ToString())