Nombre avec virgule TextBox ne me le recupere pas
Résolu
gael444
-
gael444 -
gael444 -
Bonjour,
.
J'ai un soucis j'ai créé mon formulaire vba avec toute mes saisis
mais quand je rentre un chiffre avec une virgule dans mon formulaire dans la case volume fournisseur
il me met juste le chiffre avant la virgule dans mon tableau alors qu je le voudrais entier
pouvez vous m'aider
Voici mon code
.
.
Et voici mon fichier https://www.cjoint.com/c/FIeqlvflMM1
.
J'ai un soucis j'ai créé mon formulaire vba avec toute mes saisis
mais quand je rentre un chiffre avec une virgule dans mon formulaire dans la case volume fournisseur
il me met juste le chiffre avant la virgule dans mon tableau alors qu je le voudrais entier
pouvez vous m'aider
Voici mon code
.
Private Sub CommandButton1_Click()
If ComboBox1.ListIndex = -1 Then Exit Sub
With Sheets(CStr(ComboBox1))
dl = .Range("A65000").End(xlUp).Row + 1
.Cells(dl, 1) = ComboBox2
.Cells(dl, 2) = ComboBox3
If IsNumeric(TextBox1) = True Then .Cells(dl, 3) = Val(TextBox1)
If IsNumeric(TextBox2) = True Then .Cells(dl, 4) = Val(TextBox2)
If IsNumeric(TextBox3) = True Then .Cells(dl, 5) = Val(TextBox3)
If IsNumeric(TextBox4) = True Then .Cells(dl, 6) = Val(TextBox4)
.Cells(dl, 7) = TextBox5
If IsNumeric(TextBox6) = True Then .Cells(dl, 8) = Val(TextBox6)
.Cells(dl, 9) = TextBox11
.Cells(dl, 11) = ComboBox4
If IsNumeric(TextBox12) = True Then .Cells(dl, 13) = Val(TextBox12)
End With
Efface
End Sub
.
Et voici mon fichier https://www.cjoint.com/c/FIeqlvflMM1
| EDIT : Ajout des balises de code (la coloration syntaxique).
Explications disponibles ici : ICI Merci d'y penser dans tes prochains messages. |
2 réponses
-
A la place de la ',' (virgule) as-tu essayé le séparateur '.' (point) ?
-
Bonjour,
Avez vous essayé quelque chose de ce genre ? :
If IsNumeric(TextBox6) = True Then
.Cells(dl, 8) = TextBox6.Value & " m³"
Else:
If IsNumeric(Val(TextBox6.Value)) = True And InStr(TextBox6.Value, ",") <> 0 Then .Cells(dl, 8) = CDbl(TextBox6.Value) & " m³"
If IsNumeric(TextBox6.Value) = False Then MsgBox "Valeur non numérique"
End If
Edit : Pour régler le problème du "." du pavé numérique on peut rajouter cette ligne avant le code ci-dessus :
TextBox6.Value = Replace(TextBox6.Value, ".", ",")