Ich erstelle eine Quizanwendung in vb6. Ich habe 5 Fragen, die in verschiedenen Formen verfügbar sind. Ich bin randomisiert diese Formen/Fragen. Ich füge jede Frage/jedes Formular hinzu, um es jedes Mal aufzulisten, wenn es erscheint. Wie kann ich die Randomisierung stoppen, wenn diese 5 Frage bereits aufgerufen wird?So stoppen Sie die Randomisierung, wenn eine Bedingung erfüllt ist
mein Code:
Function randnum(ByVal lower As Integer, ByVal upper As Integer) As Integer
randnum = Int((upper - lower + 1) * Rnd + lower)
End Function
Private Sub Command1_Click()
Dim correct As Integer
Dim correct1 As Integer
Dim test As Boolean
Dim i As Integer
If Option3.Value = True Then
Form3Score.Text1.Text = Val(Val(Form3Score.Text1.Text) + 1)
Else
Form3Score.Text3.Text = Val(Val(Form3Score.Text3.Text) + 1)
End If
Start:
Randomize
Select Case randnum(0, 4)
Case 0
Form3q1.Show
Unload Form3q2
Unload Form3q3
Unload Form3q4
Unload Form3q5
Form3.Text1.Text = "Q1"
test = False
For i = 0 To Form3.List1.ListCount - 1
If Form3.Text1.Text = Form3.List1.List(i) Then
test = True
GoTo Start
End If
Next
If test = False Then
Form3.List1.AddItem ("Q1")
End If
Loop
Case 1
Do Until (Val(Form3Score.Text3.Text) + Val(Form3Score.Text1.Text) = 5)
Form3q2.Show
Unload Form3q1
Unload Form3q3
Unload Form3q4
Unload Form3q5
Form3.Text1.Text = "Q2"
test = False
For i = 0 To Form3.List1.ListCount - 1
If Form3.Text1.Text = Form3.List1.List(i) Then
test = True
GoTo Start
End If
Next
If test = False Then
Form3.List1.AddItem ("Q2")
End If
Loop
Case 2
Do Until (Val(Form3Score.Text3.Text) + Val(Form3Score.Text1.Text) = 5)
Form3q3.Show
Unload Form3q2
Unload Form3q1
Unload Form3q4
Unload Form3q5
Form3.Text1.Text = "Q3"
test = False
For i = 0 To Form3.List1.ListCount - 1
If Form3.Text1.Text = Form3.List1.List(i) Then
test = True
GoTo Start
End If
Next
If test = False Then
Form3.List1.AddItem ("Q3")
End If
Loop
Case 3
Do Until (Val(Form3Score.Text3.Text) + Val(Form3Score.Text1.Text) = 5)
Form3q4.Show
Unload Form3q2
Unload Form3q3
Unload Form3q1
Unload Form3q5
Form3.Text1.Text = "Q4"
test = False
For i = 0 To Form3.List1.ListCount - 1
If Form3.Text1.Text = Form3.List1.List(i) Then
test = True
GoTo Start
End If
Next
If test = False Then
Form3.List1.AddItem ("Q4")
End If
Loop
Case 4
Do Until (Val(Form3Score.Text3.Text) + Val(Form3Score.Text1.Text) = 5)
Form3q5.Show
Unload Form3q2
Unload Form3q3
Unload Form3q4
Unload Form3q1
Form3.Text1.Text = "Q5"
test = False
For i = 0 To Form3.List1.ListCount - 1
If Form3.Text1.Text = Form3.List1.List(i) Then
test = True
GoTo Start
End If
Next
If test = False Then
Form3.List1.AddItem ("Q5")
End If
End Select
End Sub
pls ignorieren die do-Schleife. Ich habe es versucht, aber es funktioniert nicht –