Hi,
I am trying to write a program that
- Generates 3 unique random numbers between 1 and a number entered by the users in an InputBox
- Displays the 3 random number results in labels
- Count the number of Loops
So far I wrote this code but I don't know how to create the randoms to make it work.
Your help is really appreciated.
Private Sub Button1Generate_Click(sender As System.Object, e As System.EventArgs) Handles Button1Generate.Click
Dim userMsg As String
userMsg = InputBox("Please Enter A Number?", "Integer", "Enter your integer here", 500, 700)
Dim GenerateRandom As New Random(DateTime.Now.Millisecond)
Try
Dim Random1 As Integer = Integer.Parse(TextBox1Num1.Text)
Try
Random1 = GenerateRandom.Next(1, userMsg)
Do
Random2 = GenerateRandom.Next(1, userMsg)
Loop Until Random1 <> Random2
Do
Random3 = GenerateRandom.Next(1, userMsg)
Loop Until Rnadom1 <> Random3 And Rnadom2 <> Random 3
Dim RandomInt As Integer = GenerateRandom.Next(MinInt, MaxInt)
Label4Result.Text = "Number of Loops = " + RandomInt.ToString
End Try
End Sub