Probleme sur calculatrice vba
evolaine
-
lermite222 Messages postés 8724 Date d'inscription Statut Contributeur Dernière intervention -
lermite222 Messages postés 8724 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
je sais que c'est un sujet que vous avez du voir et revoir mais meme en cherchant partout je ne vois pas ce qui fait que dans mon programme le resultat est toujours de 0
si vous pouviez m'aider....
voila mon code
Private Sub numero0_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "0"
End Sub
Private Sub numero1_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "1"
End Sub
Private Sub numero2_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "2"
End Sub
Private Sub numero3_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "3"
End Sub
Private Sub numero4_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "4"
End Sub
Private Sub numero5_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "5"
End Sub
Private Sub numero6_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "6"
End Sub
Private Sub numero7_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "7"
End Sub
Private Sub numero8_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "8"
End Sub
Private Sub numero9_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "9"
End Sub
Private Sub addition_Click()
Dim nombre1 As Single
Dim nombre2 As Single
Dim resultat As Single
Dim operation As String
nombre1 = Val(TextBox_Operations.Text)
TextBox_Operations.Text = ""
operation = "+"
End Sub
Private Sub soustraction_Click()
Dim nombre1 As Single
Dim nombre2 As Single
Dim resultat As Single
Dim operation As String
nombre1 = Val(TextBox_Operations.Text)
TextBox_Operations.Text = ""
operation = "-"
End Sub
Private Sub multiplication_Click()
Dim nombre1 As Single
Dim nombre2 As Single
Dim resultat As Single
Dim operation As String
nombre1 = Val(TextBox_Operations.Text)
TextBox_Operations.Text = ""
operation = "*"
End Sub
Private Sub division_Click()
Dim nombre1 As Single
Dim nombre2 As Single
Dim resultat As Single
Dim operation As String
nombre1 = Val(TextBox_Operations.Text)
TextBox_Operations.Text = ""
operation = "/"
End Sub
Private Sub point_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "."
End Sub
Private Sub reinitialiser_Click()
TextBox_Operations.Text = ""
End Sub
Private Sub resultat_Click()
Dim nombre1 As Single
Dim nombre2 As Single
Dim resultat As Single
Dim operation As String
nombre2 = Val(TextBox_Operations.Text)
If operation = "+" Then
resultat = nombre1 + nombre2
End If
If operation = "-" Then
resultat = nombre1 - nombre2
End If
If operation = "*" Then
resultat = nombre1 * nombre2
End If
If operation = "/" Then
resultat = nombre1 / nombre2
End If
TextBox_Operations.Text = resultat
End Sub
je sais que c'est un sujet que vous avez du voir et revoir mais meme en cherchant partout je ne vois pas ce qui fait que dans mon programme le resultat est toujours de 0
si vous pouviez m'aider....
voila mon code
Private Sub numero0_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "0"
End Sub
Private Sub numero1_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "1"
End Sub
Private Sub numero2_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "2"
End Sub
Private Sub numero3_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "3"
End Sub
Private Sub numero4_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "4"
End Sub
Private Sub numero5_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "5"
End Sub
Private Sub numero6_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "6"
End Sub
Private Sub numero7_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "7"
End Sub
Private Sub numero8_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "8"
End Sub
Private Sub numero9_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "9"
End Sub
Private Sub addition_Click()
Dim nombre1 As Single
Dim nombre2 As Single
Dim resultat As Single
Dim operation As String
nombre1 = Val(TextBox_Operations.Text)
TextBox_Operations.Text = ""
operation = "+"
End Sub
Private Sub soustraction_Click()
Dim nombre1 As Single
Dim nombre2 As Single
Dim resultat As Single
Dim operation As String
nombre1 = Val(TextBox_Operations.Text)
TextBox_Operations.Text = ""
operation = "-"
End Sub
Private Sub multiplication_Click()
Dim nombre1 As Single
Dim nombre2 As Single
Dim resultat As Single
Dim operation As String
nombre1 = Val(TextBox_Operations.Text)
TextBox_Operations.Text = ""
operation = "*"
End Sub
Private Sub division_Click()
Dim nombre1 As Single
Dim nombre2 As Single
Dim resultat As Single
Dim operation As String
nombre1 = Val(TextBox_Operations.Text)
TextBox_Operations.Text = ""
operation = "/"
End Sub
Private Sub point_Click()
TextBox_Operations.Text = TextBox_Operations.Text & "."
End Sub
Private Sub reinitialiser_Click()
TextBox_Operations.Text = ""
End Sub
Private Sub resultat_Click()
Dim nombre1 As Single
Dim nombre2 As Single
Dim resultat As Single
Dim operation As String
nombre2 = Val(TextBox_Operations.Text)
If operation = "+" Then
resultat = nombre1 + nombre2
End If
If operation = "-" Then
resultat = nombre1 - nombre2
End If
If operation = "*" Then
resultat = nombre1 * nombre2
End If
If operation = "/" Then
resultat = nombre1 / nombre2
End If
TextBox_Operations.Text = resultat
End Sub
A voir également:
- Probleme sur calculatrice vba
- Installer calculatrice sur mon portable - Télécharger - Calcul & Conversion
- Calculatrice gratuit - Télécharger - Calcul & Conversion
- Comment calculer la moyenne sur excel - Guide
- Ma-calculatrice - Télécharger - Calcul & Conversion
- Calculatrice windows 7 - Télécharger - Calcul & Conversion
2 réponses
bonjour
peut etre que (au moins)
les variables nombre1, nombre2, operation devraient etre déclarés en variables globales. En les redeclarant dans chaque procedure, elles sont remises a zero
bonne suite
peut etre que (au moins)
les variables nombre1, nombre2, operation devraient etre déclarés en variables globales. En les redeclarant dans chaque procedure, elles sont remises a zero
bonne suite