Formatage textbox en €

GADENSEB

XLDnaute Impliqué
Bonjour le Forum,

Je cherche à formater des textbox dans un USF de saisie
Voici mon code

Quand je veux taper 50 j'obtiens 5,00 €0 !!!!

Code:
Private Sub CREDIT_Change()
If CREDIT.Value > 0 Then
DEBIT.Value = ""
CREDIT.Value = Format(CREDIT.Value, "#,##0.00 €")
End If
End Sub

Private Sub DEBIT_Change()
If DEBIT.Value > 0 Then
CREDIT.Value = ""
DEBIT.Value = Format(DEBIT.Value, "#,##0.00 €")
End If
End Sub

QQn aurait une idée sachant que je souhaite obtenir pour 50€, par exemple : 50.00 €

Bonne am


Seb
 

BigDaddy154

XLDnaute Junior
Re : Formatage textbox en €

Bonjour,

peut etre :

Code:
Private Sub CREDIT_Change()
If CREDIT.Value > 0 Then
DEBIT.Value = ""
CREDIT.Value = Format(CREDIT.Value, "#,##00 €")
End If
End Sub

Private Sub DEBIT_Change()
If DEBIT.Value > 0 Then
CREDIT.Value = ""
DEBIT.Value = Format(DEBIT.Value, "#,##00 €")
End If
End Sub

Cordialement
 

Paf

XLDnaute Barbatruc
Re : Formatage textbox en €

Bonjour GADENSEB, BigDaddy154, mutzik

La sub Private Sub CREDIT_Change() se déclenche dès la saisie du premier caractère et donc le format est appliqué sur ce caractère.

Une solution, n'appliquer ce format qu'en sortie de cette textbox :

Code:
Private Sub CREDIT_Exit(ByVal Cancel As MSForms.ReturnBoolean)
 If CREDIT.Value > 0 Then
    DEBIT.Value = ""
    CREDIT.Value = Format(CREDIT.Value, "#,##00 €")
 End If
End Sub

ce qui oblige à cliquer hors textbox pour déclencher le code

A+
 

GADENSEB

XLDnaute Impliqué
Re : Formatage textbox en €

Hello,

Merci à tous, cela marche nikel avec

Code:
Private Sub CREDIT_AfterUpdate()
If CREDIT.Value > 0 Then
DEBIT.Value = ""
Me.CREDIT = Format(CDbl(Me.CREDIT), "# ##0.00€")
End If
End Sub

Private Sub DEBIT_AfterUpdate()
If DEBIT.Value > 0 Then
CREDIT.Value = ""
Me.DEBIT = Format(CDbl(Me.DEBIT), "# ##0.00€")
End If
End Sub

Bon We

Seb
 

Discussions similaires

  • Question
Microsoft 365 TEXTBOX
Réponses
7
Affichages
284

Statistiques des forums

Discussions
311 733
Messages
2 082 019
Membres
101 872
dernier inscrit
Colin T