Arrêt après la 10ème question sur un random (Vb2010)
yannel777
Messages postés
129
Date d'inscription
Statut
Membre
Dernière intervention
-
yannel777 Messages postés 129 Date d'inscription Statut Membre Dernière intervention -
yannel777 Messages postés 129 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Je suis actuellement sur un projet avec des questions/réponses.
Je voudrais savoir, si il existe une commande qui arrête juste à la 10ème question,par exemple.
voici mon code:
mais cependant, il y a beaucoup d'erreurs
voici image ci-dessous:
http://img15.hostingpics.net/pics/803208152660038299917257851054748978n.jpg
Et voici un bout de mon code de mon programme:
Merci de votre compréhension
Je suis actuellement sur un projet avec des questions/réponses.
Je voudrais savoir, si il existe une commande qui arrête juste à la 10ème question,par exemple.
voici mon code:
Dim result As DialogResult Dim result2 As MsgboxResult If Label5.Text = Val(10) Then Label3.txt = "c'est fini" Timer2.Start() Timer2.Interval = 5000 Timer2.Stop() Label3.Visible = False MsgBox("Voulez vous refaire une autre partie ", vbYesNo, "p") If result = DialogResult.Yes Then Label5.text=0 InitialiserNouvelleQuestion() ElseIf result = DialogResult.No Then MsgBox("Voulez-vous quitter", vbYesNo, "p") If result2=MsgboxResult.yes then Me.close ElseIf result2=MsgboxResult.yes then Label5.text=0 InitialiserNouvelleQuestion() End If EndIf ElseIf InitialiserNouvelleQuestion() End If
mais cependant, il y a beaucoup d'erreurs
voici image ci-dessous:
http://img15.hostingpics.net/pics/803208152660038299917257851054748978n.jpg
Et voici un bout de mon code de mon programme:
Private Sub Verbes_Load_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TextBox1.TabIndex = 0 InitialiserNouvelleQuestion() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Verification() End Sub Sub Verification() If TextBox1.Text = Me.réponses(Me.numéroQuestion) Then Label3.Visible = True Label3.ForeColor = Color.Green Label3.Text = "Correct" Label5.Text = Val(Label5.Text) + 1 Timer1.Start() Timer1.Interval = 1000 Else Label2.Visible = True Label2.ForeColor = Color.Red Label2.Text = " Réponse Incorrecte" MsgBox("Votre réponse est fausse, Veuillez réessayer " & vbLf & "Your answer is wrong, please try again", vbOKOnly, "Erreur-Error") TextBox1.Focus() TextBox1.Clear() Label2.Visible = False Me.nbTentatives = Me.nbTentatives + 1 If Me.nbTentatives = 3 Then MsgBox("La Réponse est:" & vbLf & "The Answer is: " & Me.réponses(Me.numéroQuestion), 32, "Réponse") Timer1.Start() Timer1.Interval = 900 End If End If End Sub Private Sub InitialiserNouvelleQuestion() Me.nbTentatives = 0 Me.numéroQuestion = random.Next(0, questions.Length - 1) Label1.Text = Me.questions(Me.numéroQuestion) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Accueil.Dispose() End Sub Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If e.KeyChar = Chr(13) Then Verification() e.Handled = True Else e.Handled = False End If End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Timer1.Stop() TextBox1.Clear() Label3.Visible = False InitialiserNouvelleQuestion() End Sub
Merci de votre compréhension
A voir également:
- Arrêt après la 10ème question sur un random (Vb2010)
- Arrêt maladie - Guide
- La Sécurité sociale durcit les règles - Ces médecins ne pourront plus délivrer d'arrêt maladie - Guide
- Bouton marche arret i o - Forum Word
- Forcer arret application windows - Guide
- Arrêt défilement excel ✓ - Forum MacOS
1 réponse
Bonjour, j'ai enfin trouvé:
Mon code:
voilà bonne journée à tous
Mon code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Verification()
Sub Verification() If TextBox1.Text = Me.réponses(Me.numéroQuestion) Then Label3.Visible = True Label3.ForeColor = Color.Green Label3.Text = "Correct" Label5.Text = Val(Label5.Text) + 1 Timer1.Start() Timer1.Interval = 530 Else Label2.Visible = True Label2.ForeColor = Color.Red Label2.Text = " Réponse Incorrecte" MsgBox("Votre réponse est fausse, Veuillez réessayer " & vbLf & "Your answer is wrong, please try again", vbOKOnly, "Erreur-Error") TextBox1.Focus() TextBox1.Clear() Label2.Visible = False Me.nbTentatives = Me.nbTentatives + 1 If Me.nbTentatives = 3 Then MsgBox("La Réponse est - The Answer is: " & Me.réponses(Me.numéroQuestion), vbOKOnly, "Réponse") Timer1.Start() Timer1.Interval = 150 End If End If
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Timer1.Stop() TextBox1.Clear() Label3.Visible = False Labelsi10() End Sub
Sub Labelsi10() If Label5.Text = "10" Then Select Case MsgBox("Voulez vous recommencer une autre partie?" & vbLf & "Do you want to start another party?", vbYesNo, "Recommencer-Restart") Case MsgBoxResult.Yes Label1.Text = "" Label5.Text = "0" InitialiserNouvelleQuestion() ' Do something if yes Case MsgBoxResult.No ' Do something if no Accueil.Show() Me.Hide() End Select Else InitialiserNouvelleQuestion() End If End Sub
voilà bonne journée à tous