Operation de devision ne fonctionne ps (vb 6.0)

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

  • Votes
  • Date
  • Date décroissante
  1. 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+
    1. mercii bcppppppp :D
      1. 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+.
    2. 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
      1. 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
        1. 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+