Bonjour,
Je voudrais ajouter un 0 à la fin d'un string mais ça marche pas :cry:
Quelqu'un a une idée ?Code:
1
2
3
4
5 dim thisString as string thisString = "605.1" thisString = thisString & "0" 'retourne 605.1 mais je voudrais 605.10
Version imprimable
Bonjour,
Je voudrais ajouter un 0 à la fin d'un string mais ça marche pas :cry:
Quelqu'un a une idée ?Code:
1
2
3
4
5 dim thisString as string thisString = "605.1" thisString = thisString & "0" 'retourne 605.1 mais je voudrais 605.10
Chez moi:
Renvoit la valeur '605.10'Code:
1
2
3
4
5
6
7
8 Option Explicit Private Sub Test() Dim thisString As String thisString = "605.1" thisString = thisString & "0" Debug.Print (thisString) End Sub
Si tu l'envoies sur une cellule Excel il faut peut être modifier le format de la cellule en 'Texte'.
Merci pour ta réponse!
En effet, je l'envoies dans une cellule mais ça marche pas même en changeant le format de la cellule en "texte".
D'autres idées ?
Et avec ce code ?
Code:
1
2
3
4
5
6
7
8
9
10
11
12 Option Explicit Private Sub Test() Dim thisString As String thisString = "605.1" thisString = thisString & "0" 'Cellule à modifier With Cells(1, 1) .NumberFormat = "@" .Value = thisString End With End Sub
Bonjour
un exemple
Code:
1
2
3
4 Sub test() [a1] = 605.1 [a1].NumberFormat = "0.00" End Sub
Bonjour.
De toute manière si la cellule est bien en format texte avant l'exécution du code,
cela fonctionne directement avec [cellule] = thisString ‼
Bonjour,
J'aurai fait comme ci dessous :
A vos claviers !Code:
1
2
3
4
5
6 Sub test() Dim sValeur As String sValeur = Format("605,1", "# ###.00") Debug.Print sValeur End Sub