本文介绍了为什么会导致无限循环错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图制作东西,产生随机数,不包括previos(1-10)
im trying to make thing,that generates random number, not includes previos(1-10)
Public Class Form1
Dim NewTicketNumber As Integer
Dim IsTicketDone1 As Boolean = False
Dim IsTicketDone2 As Boolean = False
Dim IsTicketDone3 As Boolean = False
Dim IsTicketDone4 As Boolean = False
Dim IsTicketDone5 As Boolean = False
Dim IsTicketDone6 As Boolean = False
Dim IsTicketDone7 As Boolean = False
Dim IsTicketDone8 As Boolean = False
Dim IsTicketDone9 As Boolean = False
Dim IsTicketDone10 As Boolean = False
Private Sub Make()
NewTicketNumber = GetRandom(1, 10)
If NewTicketNumber = 1 Then
If IsTicketDone1 = True Then
Make()
Else
IsTicketDone1 = True
End If
ElseIf NewTicketNumber = 2 Then
If IsTicketDone2 = True Then
Make()
Else
IsTicketDone2 = True
End If
ElseIf NewTicketNumber = 3 Then
If IsTicketDone3 = True Then
Make()
Else
IsTicketDone3 = True
End If
ElseIf NewTicketNumber = 4 Then
If IsTicketDone4 = True Then
Make()
Else
IsTicketDone4 = True
End If
ElseIf NewTicketNumber = 5 Then
If IsTicketDone5 = True Then
Make()
Else
IsTicketDone5 = True
End If
ElseIf NewTicketNumber = 6 Then
If IsTicketDone6 = True Then
Make()
Else
IsTicketDone6 = True
End If
ElseIf NewTicketNumber Then
If IsTicketDone7 = True Then
Make()
Else
IsTicketDone7 = True
End If
ElseIf NewTicketNumber Then
If IsTicketDone8 = True Then
Make()
Else
IsTicketDone8 = True
End If
ElseIf NewTicketNumber Then
If IsTicketDone9 = True Then
Make()
Else
IsTicketDone9 = True
End If
ElseIf NewTicketNumber Then
If IsTicketDone10 = True Then
Make()
Else
IsTicketDone10 = True
End If
End If
Label1.Text = NewTicketNumber
If IsTicketDone1 = True And IsTicketDone2 = True And IsTicketDone3 = True And IsTicketDone4 = True And IsTicketDone5 = True And IsTicketDone6 = True And IsTicketDone7 = True And IsTicketDone8 = True And IsTicketDone9 = True And IsTicketDone10 = True Then
MsgBox("All Done!")
End If
End Sub
Public Function GetRandom(ByVal Min As Integer, ByVal Max As Integer) As Integer
Dim Generator As System.Random = New System.Random()
Return Generator.Next(Min, Max)
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Make()
End Sub
End Class
推荐答案
这篇关于为什么会导致无限循环错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!