sto facendo una specie di gioco a quiz, volevo sapere se utilizzando la funzione random, quest'ultima dovrebbe impedire che la stessa domanda si ripresenti, esiste un modo per evitare che in random esce sempre la stessa domanda?
vi posto il codice che sto realizzando alla quale vorrei capire come evitare il problema menzionato.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmddomanda.Click
TextBox1.Text = Int(Rnd() * 8)
Select Case TextBox1.Text
Case 0
TextBox1.Text = "Gesù era sposato?"
Case 2
TextBox1.Text = "Catania è il capoluogo della Sicilia?"
Case 3
TextBox1.Text = "Garibaldi sbarcò a Trapani?"
Case 4
TextBox1.Text = "Edison inventò la luce?"
Case 5
TextBox1.Text = "Il pianeta terra è uguale a marte?"
Case 6
TextBox1.Text = "I dinosauri sono Vegetareani?"
End Select
TextBox2.Text = ""
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsi.Click
If TextBox1.Text = "Gesù era sposato?" Then
TextBox2.Text = "Sbagliato"
Else
If TextBox1.Text = "il computer è intelligente?" Then
TextBox2.Text = "Sbagliato"
TextBox2.Text = "Sbagliato"
Else
If TextBox1.Text = "Catania è il capoluogo della Sicilia?" Then
TextBox2.Text = "Sbagliato"
Else
If TextBox1.Text = "Garibaldi sbarcò a Trapani?" Then
TextBox2.Text = "Sbagliato"
Else
If TextBox1.Text = "Edison inventò la luce?" Then
TextBox2.Text = "Sbagliato"
Else
If TextBox1.Text = "Il pianeta terra è uguale a marte?" Then
TextBox2.Text = "Sbagliato"
Else
If TextBox1.Text = "I dinosauri sono Vegetareani?" Then
TextBox2.Text = "Sbagliato"
End If
End If
End If
End If
End If
End If
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdno.Click
If TextBox1.Text = "Gesù era sposato?" Then
TextBox2.Text = "Esatto!!"
Else
If TextBox1.Text = "il computer è intelligente?" Then
TextBox2.Text = "Esatto!!"
Else
If TextBox1.Text = "Catania è il capoluogo della Sicilia?" Then
TextBox2.Text = "Esatto!!"
Else
If TextBox1.Text = "Garibaldi sbarcò a Trapani?" Then
TextBox2.Text = "Esatto!!"
Else
If TextBox1.Text = "Edison inventò la luce?" Then
TextBox2.Text = "Esatto!!"
Else
If TextBox1.Text = "Il pianeta terra è uguale a marte?" Then
TextBox2.Text = "Esatto!!"
Else
If TextBox1.Text = "I dinosauri sono Vegetareani?" Then
End If
End If
TextBox2.Text = "Esatto!!"
End If
End If
End If
End If
End If
End Sub
End Class
|