Calcul entre TextBox

Bonsoir à toutes et tous

j'ai une formule qui calcule un montant entre deux TB, mais le résultat ne s'affiche pas dans la TB résultat TB5

Private Sub TextBox5_Change()    ' Modif
TextBox5.Value = (CDbl(TextBox4.Value) * CDbl(TextBox3.Value))
  Const Num1 = "##,###.00 €"
TextBox5.Text = Format(TextBox5.Text, Num1)

End Sub

que manque-t-il à ce code ?

merci de votre aide

Pierrot

Bonjour,

en testant, la virgule par un point

crdlt,

André

Bonjour André

merci de ton intérêt, mais cela ne marche pas mieux

amicalement

Pierrot

Bonjour

Un essai :

Private Sub TextBox4_Change()
    TextBox5 = ""
    If TextBox4 <> "" And TextBox3 <> "" Then
        TextBox5 = Replace(TextBox4, ".", ",") * Replace(TextBox3, ".", ",")
    End If
End Sub

Private Sub TextBox3_Change()
    TextBox5 = ""
    If TextBox4 <> "" And TextBox3 <> "" Then
        TextBox5 = Replace(TextBox4, ".", ",") * Replace(TextBox3, ".", ",")
    End If
End Sub

Bye !

Salut, gmb

C'est tout simplement parfait

seulement, mes TB3 et 4 ne s'affichent pas au format nombre

Amitiés

Pierrot

bonjour

une seule ligne

TextBox5.Value = Format(CDbl(TextBox4.Value) * CDbl(TextBox3.Value), "##,###.00 €")

A+

Maurice

Bonjour, Maurice

merci de ton aide, mais le TextBox5 (Résultat)ne se remplit pas automatiquement, les autres TB3et TB4 ne s'affichent pas en numérique

Voir fichier joint

amitiés

Pierrot

Bonjour,Pierre

voila des modifes a toi de voir si ça te va

  • Private Sub UserForm_Initialize()
    ComboBox1.AddItem ("Boulangerie")
    ComboBox1.AddItem ("Boucherie")
    ComboBox1.AddItem ("Autres")
    '********** Modif
    TextBox5.Locked = True
    End Sub
    Private Sub TextBox3_keyPress(ByVal KeyAsCii As MSForms.ReturnInteger)
    If InStr("0123456789", Chr(KeyAsCii)) = 0 Then KeyAsCii = 0: Beep
    End Sub
    Private Sub TextBox4_KeyPress(ByVal KeyAsCii As MSForms.ReturnInteger)
    'TRANSFORMER LE POINT PAR UNE VIRGULE
    If KeyAsCii = 46 Then KeyAsCii = 44
    'ACCEPTER UNIQUEMENT UNE SEULE VIRGULE ET LES CHIFFRES ENTRE 0 ET 9
    If InStr("1234567890,", Chr(KeyAsCii)) = 0 Or (InStr(TextBox4.Value, ",") <> 0 And Chr(KeyAsCii) = ",") _
    Or (TextBox4.SelStart = 0 And Chr(KeyAsCii) = ",") Then KeyAsCii = 0: Beep
    End Sub
    Private Sub TextBox3_Enter()
    TextBox3.Value = Format(TextBox3.Value, "# ##0")
    End Sub
    Private Sub TextBox4_Enter()
    TextBox4.Value = Format(TextBox4.Value, "# ##0.00")
    End Sub
    Private Sub TextBox5_Enter()
    TextBox5.Value = Format(CDbl(TextBox4.Value) * CDbl(TextBox3.Value), "# ##0.00 €")
    End Sub

A+

Maurice

Bonjour

encore moi & encore des modife

A+

Maurice

319classeur-testcp.xlsm (24.30 Ko)

Salut Archer, tu tire comme Robin des Bois, c'est parfait

merci beaucoup pour ce boulot

Amitiés

Pierrot

Rechercher des sujets similaires à "calcul entre textbox"