Operation de devision ne fonctionne ps (vb 6.0)

aloulou007 Messages postés 18 Statut Membre -  
 Yoda -
je fais une alculatrice mais loperation de devision ne fonctionne ps

Private Sub Command1_Click()
If Option1.Value = True Then
Label4 = CInt(Text2.Text) + CInt(Text3.Text)
End If
If Option2.Value = True Then
Label4 = CInt(Text2.Text) - CInt(Text3.Text)
End If
If Option3.Value = True Then
Label4 = CInt(Text2.Text) * CInt(Text3.Text)
End If
If Option4.Value = True Then
If (CInt(Text2.Text) = 0 Or CInt(Text3.Text) = 0) Or (CInt(Text2.Text) = 0 And CInt(Text3.Text) = 0) Then
MsgBox " chifre 1 et 2 doivent etre diff de 0"
Label4 = CInt(Text2.Text) \ CInt(Text3.Text)
End If
End If
End Sub

5 réponses

  1. Yoda
     
    Bonjour,

    If Option4.Value = True Then 
       If (CInt(Text2.Text) = 0 Or CInt(Text3.Text) = 0) Or (CInt(Text2.Text) = 0 And  CInt(Text3.Text) = 0) Then 
          MsgBox " chifre 1 et 2 doivent etre diff de 0" 
        Else
          Label4 = CInt(Text2.Text) \ CInt(Text3.Text) 
        End If 
    End If 


    A+
    0
  2. aloulou007 Messages postés 18 Statut Membre
     
    mercii bcppppppp :D
    0
    1. Yoda
       
      Y a pas de quoi.

      Mais pour avoir un resultat juste à la division, tu devrais plutot utiliser l'opérarteur "/" et non "\" qui est l'opérateur de division entière.

      exemple :
      3 \ 2 = 1
      3 / 2 = 1.5

      A+.
      0
  3. aloulou007 Messages postés 18 Statut Membre
     
    g 3 text box en cliquant sur un bouton le minimum saffiche dns un label c quoi le probleme?
    Sub minim(x As Integer, y As Integer, min As Integer)
    If x < min Then

    x = min
    End If
    If z < min Then
    z = min
    End If
    Label8.Caption = min
    End Sub

    Private Sub comparer_Click()
    Dim nb1 As Integer
    Dim nb2 As Integer
    Dim nb3 As Integer
    nb1 = CInt(Text1.Text)
    nb2 = CInt(Text2.Text)
    nb3 = CInt(Text3.Text)
    Call minim(comparer(nb1, nb2, nb3))
    End Sub
    0
  4. lermite222 Messages postés 9042 Statut Contributeur 1 199
     
    Bonjour,
    Une autre façon de faire une calculatrice Voir cette démo
    Une approche comme toi, avec deux textbox Projet calculateur
    A+
    0
  5. Vous n’avez pas trouvé la réponse que vous recherchez ?

    Posez votre question
  6. aloulou007 Messages postés 18 Statut Membre
     
    g 3 text box en cliquant sur un bouton le minimum saffiche dns un label c quoi le probleme? !!!!!!!!!!!!!!!!!!!!!!!!
    Sub minim(x As Integer, y As Integer, min As Integer)
    If x < min Then

    x = min
    End If
    If z < min Then
    z = min
    End If
    Label8.Caption = min
    End Sub

    Private Sub comparer_Click()
    Dim nb1 As Integer
    Dim nb2 As Integer
    Dim nb3 As Integer
    nb1 = CInt(Text1.Text)
    nb2 = CInt(Text2.Text)
    nb3 = CInt(Text3.Text)
    Call minim(comparer(nb1, nb2, nb3))
    End Sub
    0
    1. Yoda
       
      Bonjour,

      Il y a plusieurs problèmes:

      1/ la Sub minim() a trois paramètres, x , y et min
      et dans le corps de la sub on voit x, z et min

      2/ le Call est incorrect, il faut écrire Call minim(nb1,nb2,nb3)

      3/ ton raisonnement pour trouver le minimun de trois nombre est faux, je te laisse réfléchir un peu.

      A+
      0