我正试图制造一个非常简单的模拟器。 彩票有6个,产生的数量必须在1 - 49之间,不能在下个数字中。 我已尝试利用其他资源的功能,但我并不完全相信,如果我适当利用这一职能。 任何帮助都是巨大的。 感谢。
Public Class Form1
Private Sub cmdRun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRun.Click
#Creates a new Random class in VB.NET
Dim RandomClass As New Random()
####################################
Dim RandomNumber1 As Integer
RandomNumber1 = RandomClass.Next(1, 49)
#Displays first number generated
txtFirst.Text = (RandomNumber1)
####################################
Dim RandomNumber2 As Integer
RandomNumber2 = RandomClass.Next(1, 49)
If RandomNumber2 = RandomNumber1 Then
RandomNumber2 = RandomClass.Next(1, 49)
End If
#Displays second number generated
txtSecond.Text = (RandomNumber2)
####################################
Dim RandomNumber3 As Integer
RandomNumber3 = RandomClass.Next(1, 49)
If RandomNumber3 = RandomNumber2 Or RandomNumber2 Then
RandomNumber3 = RandomClass.Next(1, 49)
End If
#Displays third number generated
txtThird.Text = (RandomNumber3)
####################################
Dim RandomNumber4 As Integer
RandomNumber4 = RandomClass.Next(1, 49)
If RandomNumber4 = RandomNumber3 Or RandomNumber2 Or RandomNumber1 Then
RandomNumber4 = RandomClass.Next(1, 49)
End If
#Displays fourth number generated
txtFourth.Text = (RandomNumber4)
####################################
Dim RandomNumber5 As Integer
RandomNumber5 = RandomClass.Next(1, 49)
If RandomNumber5 = RandomNumber4 Or RandomNumber3 Or RandomNumber2 Or RandomNumber1 Then
RandomNumber5 = RandomClass.Next(1, 49)
End If
#Displays fifth number generated
txtFifth.Text = (RandomNumber5)
####################################
Dim RandomNumber6 As Integer
RandomNumber6 = RandomClass.Next(1, 49)
If RandomNumber6 = RandomNumber5, RandomNumber4, RandomNumber3, RandomNumber2, RandomNumber1 Then
RandomNumber6 = RandomClass.Next(1, 49)
End If
#Displays sixth number generated
txtSixth.Text = (RandomNumber6)
End Sub