cs_seyna
Messages postés3Date d'inscriptiondimanche 11 mai 2008StatutMembreDernière intervention24 mai 2008
-
23 mai 2008 à 23:02
vecchio56
Messages postés6535Date d'inscriptionlundi 16 décembre 2002StatutMembreDernière intervention22 août 2010
-
24 mai 2008 à 22:01
Salut à tous!
là j'ai besoin d'aide.
je suis débutante en programmation et ça m'interresse vraiment.
là je suis sur la programmation de la calculatrice simple comme celle de windows.
jai un probleme avec le code.quand j'additionne des chiffres dècimaux la virgule n'est pas prise en compte par exemple:
2.5 + 2 me donne 4 ; pour les autres signes c'est ok
comment puis je corriger cela ?
Merci de m'aider.
cs_seyna
Messages postés3Date d'inscriptiondimanche 11 mai 2008StatutMembreDernière intervention24 mai 2008 24 mai 2008 à 21:38
oui ben voila tout le code:
Public op As String
Public neg As String
Public ind As Boolean
Public tampon As String
Public rest As Boolean
Private Sub addition_Click()
op = "+"
ind = True
rest = True
End Sub
Private Sub Command2_Click()
op = "-"
ind = True
resultat.Text = "-" & resultat.Text
End Sub
Private Sub egal_Click()
If (op = "+") Then
resultat.Text = Val(tampon) + Val(resultat.Text)
ElseIf (op = "-") Then
resultat.Text = tampon - resultat.Text
ElseIf (op = "*") Then
resultat.Text = tampon * resultat.Text
ElseIf (op = "/") And resultat.Text <> 0 Then
resultat.Text = tampon / resultat.Text
Else: resultat.Text = "erreur"
End If
End Sub
Private Sub Form_Load()
ind = False
rest = False
End Sub
Private Sub nb10_Click()
neg = "-"
resultat.Text = "-" & resultat.Text
End Sub
Private Sub ress_Click()
ress = "0"
resultat.Text = "0"
End Sub
Private Sub soustraction_Click()
op = "-"
ind = True
rest = True
End Sub
Private Sub division_Click()
op = "/"
ind = True
rest = True
End Sub
Private Sub multiplication_Click()
op = "*"
ind = True
rest = True
End Sub
Private Sub nb0_Click()
If ind = True Then
tampon = resultat.Text
resultat.Text = "0"
ind = False
ElseIf resultat.Text = "0" Then
resultat.Text = "0"
Else
resultat.Text = resultat.Text & "0"
End If
End Sub
Private Sub nb1_Click()
If (ind = True) Then
tampon = resultat.Text
resultat.Text = "1"
ind = False
ElseIf resultat.Text = "0" Then
resultat.Text = "1"
Else
resultat.Text = resultat.Text & "1"
End If
End Sub
Private Sub nb2_Click()
If (ind = True) Then
tampon = resultat.Text
resultat.Text = "2"
ind = False
ElseIf resultat.Text = "0" Then
resultat.Text = "2"
Else
resultat.Text = resultat.Text & "2"
End If
End Sub
Private Sub nb3_Click()
If ind = True Then
tampon = resultat.Text
resultat.Text = "3"
ind = False
ElseIf resultat.Text = "0" Then
resultat.Text = "3"
Else
resultat.Text = resultat.Text & "3"
End If
End Sub
Private Sub nb4_Click()
If ind = True Then
tampon = resultat.Text
resultat.Text = "4"
ind = False
ElseIf resultat.Text = "0" Then
resultat.Text = "4"
Else
resultat.Text = resultat.Text & "4"
End If
End Sub
Private Sub nb5_Click()
If ind = True Then
tampon = resultat.Text
resultat.Text = "5"
ind = False
ElseIf resultat.Text = "0" Then
resultat.Text = "5"
Else
resultat.Text = resultat.Text & "5"
End If
End Sub
Private Sub nb6_Click()
If ind = True Then
tampon = resultat.Text
resultat.Text = "6"
ind = False
ElseIf resultat.Text = "0" Then
resultat.Text = "6"
Else
resultat.Text = resultat.Text & "6"
End If
End Sub
Private Sub nb7_Click()
If ind = True Then
tampon = resultat.Text
resultat.Text = "7"
ind = False
ElseIf resultat.Text = "0" Then
resultat.Text = "7"
Else
resultat.Text = resultat.Text & "7"
End If
End Sub
Private Sub nb8_Click()
If ind = True Then
tampon = resultat.Text
resultat.Text = "8"
ind = False
ElseIf resultat.Text = "0" Then
resultat.Text = "8"
Else
resultat.Text = resultat.Text & "8"
End If
End Sub
Private Sub nb9_Click()
If ind = True Then
tampon = resultat.Text
resultat.Text = "9"
ind = False
ElseIf resultat.Text = "0" Then
resultat.Text = "9"
Else
resultat.Text = resultat.Text & "9"
End If
End Sub
Private Sub virgule_Click()
resultat.Text = resultat.Text & ","
End Sub
pas mal d'erreur je suppose
Peace And Love!!!
Vous n’avez pas trouvé la réponse que vous recherchez ?