Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

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
 

Scorpio

XLDnaute Impliqué
Re
J'ai fait comme ça, mais rien a faire

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 46 Then KeyAscii = 44
TextBox1.Value = (Format(val(Me.TextBox1.Value), "0,00"))
End Sub
 

Eric 45

XLDnaute Occasionnel
Re

En ne mettant que cela :
Code:
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 46 Then KeyAscii = 44
End Sub
Sur quelle touche appuies-tu pour faire le "." ?

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 ?
 

Scorpio

XLDnaute Impliqué
Salut Dranreb,
Alors je suis pas sur d'un Label, mais pourquoi pas.
Et pour le code Integer de Calc, vous savez, je ne suis pas un as en BVA, alors voilà, j'aimerais bien une solution, qui fonctionne.
Merci Dranreb de ton aide
 

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

Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…