XL 2013 Format textbox

maval

XLDnaute Barbatruc
Bonjour,

Je cherche à mettre un format à mes textBox comme ceci 100 000

J'ai fait ceci TextBox = Format("# ##0")
et après ceci
VB:
Private Sub TextBox2_AfterUpdate()
On Error Resume Next
Me.TextBox2.Value = Format(Val(Replace(TextBox2, ",", ".")), "#,##0.00")

End Sub

Sa ne fonctionne toujours pas?

Merci de votre aide
 
Dernière édition:

ChTi160

XLDnaute Barbatruc
Re
pour le Fun !
Pense à faire un fichier exemple Lol
une approche.
On peut utiliser ou la version avec Classe1 ou pas (voir le Code) Lol
au départ on formate lors du remplissage des TextBox (voir le Code)
jean marie
 

Pièces jointes

  • maval TxtB.xlsm
    27 KB · Affichages: 5

patricktoulon

XLDnaute Barbatruc
re
je pige pas la si c'est alimenter par le click de la combo et que les valeurs sontprises dans les cellule pourquoi passer par le afterupdate
fait le directement par la combo et la fonction
VB:
Private Sub Combobox1_Click()

Dim lign As Long

    If ComboBox1.Value <> "" Then
        
        lign = ComboBox1.ListIndex + 6
        TextBox1.Value = format_textbox(Range("A" & lign))
        TextBox2.Value = format_textbox(Range("C" & lign))
        TextBox3.Value = format_textbox(Range("D" & lign))
        TextBox4.Value = format_textbox(Range("E" & lign))
        TextBox5.Value = format_textbox(Range("F" & lign))
        TextBox6.Value = format_textbox(Range("G" & lign))
        TextBox7.Value = format_textbox(Range("H" & lign))
        TextBox8.Value = format_textbox(Range("I" & lign))
        TextBox9.Value = format_textbox(Range("J" & lign))
        TextBox10.Value = format_textbox(Range("K" & lign))
        TextBox11.Value = format_textbox(Range("L" & lign))
        TextBox12.Value = format_textbox(Range("M" & lign))
        TextBox13.Value = format_textbox(Range("N" & lign))
        TextBox14.Value = format_textbox(Range("O" & lign))
        TextBox15.Value = format_textbox(Range("P" & lign))
        TextBox16.Value = format_textbox(Range("Q" & lign))
        TextBox17.Value = format_textbox(Range("R" & lign))
        TextBox18.Value = format_textbox(Range("S" & lign))
        TextBox19.Value = format_textbox(Range("T" & lign))
    End If
    
End Sub

Private Function format_textbox(rng As Range)
       res = Replace(rng.Value, ".", ",")
       res = Format(CCur(rng.Value), "### ### ##0.00")
   format_textbox = res
End Function
et meme la on pourrait simplifier avec un boucle pour les textbox 1 a 19
 

patricktoulon

XLDnaute Barbatruc
UN PETIT EXEMPLE vite fait
demo3.gif
 

Pièces jointes

  • MAVAL.xlsm
    15 KB · Affichages: 7

ChTi160

XLDnaute Barbatruc
Bonjour maval
c est pas comme cela qu il faut voir la Chose.
regarde mon post #10
c etait sans fichier.
une fois que tu as eut joint un fichier , ca etait beaucoup mieux pour tout le monde lol
je me suis meme apercu que ce n etait pas des sommes(CCur),mais des nombres entiers(populations),plus besoin de ce format avec virgule.
moralite , avant de poser une question ,fait un petit fichier et toi meme tu vas gagner du temps.
j ai aussi vu ton poste qui traite des images.
Bonne journee
jean marie
 
Dernière édition:

Discussions similaires

Réponses
15
Affichages
494

Statistiques des forums

Discussions
312 195
Messages
2 086 079
Membres
103 112
dernier inscrit
cuq-laet