Pas d'accès à ma seconde form pour répondre
Bonjour :coucou:
Je fais un prog pour ma fille pour l'aider à apprendre ses tables de multiplication (je suis rouillée :cry: car j'ai pris 3 ans de congé parental et cela m'aide à m'y remettre :ccool:)
Ma première form s'affiche niquel : :D
Elle demande à l'utilisateur quelle table il veut tester (pour l'instant je me suis limité à la table 1 pour tester mon prog)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
Public Class Form1
Public t1, t2, t3, t4, t5, t6, t7, t8, t9, t10 As Integer
Public tabnombreArray() As Integer = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'initialisation des variables
t1 = 0
t2 = 0
t3 = 0
t4 = 0
t5 = 0
t6 = 0
t7 = 0
t8 = 0
t9 = 0
t10 = 0
'test si la table est sélectionnée pour le quizz
If CheckBox1.Checked Then
t1 = 1
End If
If CheckBox2.Checked Then
t2 = 2
End If
If CheckBox3.Checked Then
t3 = 3
End If
If CheckBox4.Checked Then
t4 = 4
End If
If CheckBox5.Checked Then
t5 = 5
End If
If CheckBox6.Checked Then
t6 = 6
End If
If CheckBox7.Checked Then
t7 = 7
End If
If CheckBox8.Checked Then
t8 = 8
End If
If CheckBox9.Checked Then
t9 = 9
End If
If CheckBox10.Checked Then
t10 = 10
End If
'test aucune table de sélectionnée
If (t1 = 0 And t2 = 0 And t3 = 0 And t4 = 0 And t5 = 0 And t6 = 0 And t7 = 0 And t8 = 0 And t9 = 0 And t10 = 0) Then
Dim Message As String = "Vous n'avez pas sélectionné de table ? "
Dim Caption As String = "Erreur"
Dim Buttons As MessageBoxButtons = MessageBoxButtons.OK
'affichage d'un message
MessageBox.Show(Message, Caption, Buttons)
End If
Form2.Show()
End Sub
End Class |
Dans ma 2ème form, je veux afficher dans label 1 , la formule à trouver (exemple : 1*5 = ) , le prog calcule la solution et la compare à la réponse
Pour l'instant j'essaye de l'empêcher de continuer tant qu'il ne trouve pas la bonne réponse mais après je voudrais lui donner 5 seconde pour trouver sinon cela s'affiche perdu (2 secondes) et on poursuit avec un autre nombre.
Mon problème est que je n'ai pas accès à ma 2ème form, :cry: je n'arrive pas à entrer dans ma form pour taper ma solution et même pire le label n'affiche rien !! :cry: Comme je n'arrive pas à entrer dans ma form cela fait une boucle sans fin et je ne sais pas comment faire ??? :calim2:Une idée serait très bienvenue !! :lol:
J'ai testé en mettant un messagebox, cela fait s'arrêter ma boucle mais je n'ai toujours pas accès à ma form et donc à mon textbox, par contre je vois (quand je met la vérification après ma boucle until, que la boucle for se fait bien...:calim2:)
Je fais une erreur quelque part mais où ???
Merci de prendre le temps de m'éclairer de vos lumières.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| Public Class Form2
Dim solution, reponse As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For i As Integer = 0 To 10
solution = Form1.tabnombreArray(i) * Form1.t1
Label1.Text = Form1.tabnombreArray(i).ToString + " * " + Form1.t1.ToString
Do Until reponse = solution
reponse = Val(TextBox1.Text)
If (solution = reponse) Then
Label2.Text = "GAGNE"
Else
Label2.Text = "PERDU"
End If
Loop
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class |