XL 2010 Format numérique Textbox USF, 2 chiffres après le point

Scorpio

XLDnaute Impliqué
Bonjour à tous,
J'aimerais juste connaître le format à utiliser dans un Textbox, dans un USF, pour afficher fidèlement le chiffre ex: 45.67, au lieur de 45.00
J'ai essayer tous ces formats, mais rien de rien.
Private Sub TextBox1_Change()
'TextBox1 = Format(TextBox1, "0.00")
'TextBox1.Value = Round(val(TextBox1.Value), 2)
'TextBox1.Value = Format(TextBox1, "#,##0.00")
'TextBox1.Value = (Format(val(Me.TextBox1.Value), "0.00"))
'TextBox1.Value = Format(TextBox1, "# ##0")
TextBox1.Value = Format(TextBox1.Value, "### ### ##0.00")
End Sub
A ++++ merci
 

Eric 45

XLDnaute Occasionnel
Bonjour à tous
Bonjour Scorpio

Peut-être comme ceci :
Code:
'remplace le point par une virgule

Private Sub TextBox4_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 46 Then KeyAscii = 44
End Sub
si j'ai bien compris

Eric
 

Dranreb

XLDnaute Barbatruc
Bonjour.
Maintenant qu'il y a un classeur joint, j'ai deux questions.
1) – Êtes vous sûr que ce ne serait pas plutôt un Label qu'il vous faudrait ?
2) – Êtes vous sûr du type Integer de Calc, qui ne supporte que des entiers ?
 

Dranreb

XLDnaute Barbatruc
VB:
'Somme colonne "D"
Private Sub CommandButton1_Click()
Dim I As Integer, Calc As Currency
With ListBox1
   For I = 0 To .ListCount - 1
   Calc = Calc + .List(I, 4)
   Next
End With
TextBox1.Text = Format(Calc, "### ### ##0.00")
'À terme, plutôt :
'LabSomme.Caption = Format(Calc, "### ### ##0.00")
End Sub
 

Lone-wolf

XLDnaute Barbatruc
Bonjour à tous :)

Tu peux aussi faire comme ceci

VB:
Private Sub ComboBox1_Change()
If ComboBox1.Text <> "" Then
Call Afficher
Else
Exit Sub
End If
End Sub

Private Sub Afficher()
Dim I As Single, k As Integer, Calc As Currency
Dim MyArray(20, 5)
ListBox1.ColumnCount = 5 'NB de colonne
ligne = 0
DerLigne = Range("A65535").End(xlUp).Row
For I = 2 To DerLigne
If Cells(I, 1) = ComboBox1 Then
MyArray(ligne, 0) = Cells(I, 1)
MyArray(ligne, 1) = Cells(I, 3)
MyArray(ligne, 2) = Cells(I, 6)
MyArray(ligne, 3) = Cells(I, 8)
MyArray(ligne, 4) = Cells(I, 9)
ligne = ligne + 1
End If
Next I
ListBox1.List() = MyArray

With ListBox1
   For k = 0 To .ListCount - 1
   Calc = Calc + .List(k, 4)
   Next
End With
TextBox1.Text = Format(Calc, "### ### ##0.00")
End Sub
 

Scorpio

XLDnaute Impliqué
Re Dranreb,
Super, tu es un champion, formidable, c'est bon cette fois
Un grand merci à toi.

Salut Lone-Wolf,
Merci pour ton aide aussi, vous voyez, pour vous c'est facile tous ça, mais par pour moi, hai, hai, hai, dur , dur
Merci à vous 2
A++++
 

Discussions similaires

Statistiques des forums

Discussions
312 202
Messages
2 086 180
Membres
103 152
dernier inscrit
Karibu