Chiffre en Lettre
samson1977
-
Mike-31 Messages postés 18405 Date d'inscription Statut Contributeur Dernière intervention -
Mike-31 Messages postés 18405 Date d'inscription Statut Contributeur Dernière intervention -
J'ai un macro qui transforme les chiffres en lettre, mais le problème qu'il lise 2 Chiffres après le virgule, je veux le transformer en trois chiffres après le virgule. par exemple qu'on je met 230.354 ce macro me donne "deux cent trente dinars trente cinq millimes" au lieu de "deux cent trente dinars trois cent cinquante quatre millimes".
meilleures salutations.
voici le macro :
Function chiffrelettre(chiffre) ' Youky
Dim a As Variant, gros As Variant
a = Array("", "un", "deux", "trois", "quatre", "cinq", "six", "sept", _
"huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix sept", _
"dix huit", "dix neuf", "vingt", "vingt et un", "vingt deux", "vingt trois", "vingt quatre", _
"vingt cinq", "vingt six", "vingt sept", "vingt huit", "vingt neuf", "trente", "trente et un", _
"trente deux", "trente trois", "trente quatre", "trente cinq", "trente six", "trente sept", _
"trente huit", "trente neuf", "quarante", "quarante et un", "quarante deux", "quarante trois", _
"quarante quatre", "quarante cinq", "quarante six", "quarante sept", "quarante huit", _
"quarante neuf", "cinquante", "cinquante et un", "cinquante deux", "cinquante trois", _
"cinquante quatre", "cinquante cinq", "cinquante six", "cinquante sept", "cinquante huit", _
"cinquante neuf", "soixante", "soixante et un", "soixante deux", "soixante trois", _
"soixante quatre", "soixante cinq", "soixante six", "soixante sept", "soixante huit", _
"soixante neuf", "soixante dix", "soixante et onze", "soixante douze", "soixante treize", _
"soixante quatorze", "soixante quinze", "soixante seize", "soixante dix sept", _
"soixante dix huit", "soixante dix neuf", "quatre-vingts", "quatre-vingt un", _
"quatre-vingt deux", "quatre-vingt trois", "quatre-vingt quatre", "quatre-vingt cinq", _
"quatre-vingt six", "quatre-vingt sept", "quatre-vingt huit", "quatre-vingt neuf", _
"quatre-vingt dix", "quatre-vingt onze", "quatre-vingt douze", "quatre-vingt treize", _
"quatre-vingt quatorze", "quatre-vingt quinze", "quatre-vingt seize", "quatre-vingt dix sept", _
"quatre-vingt dix huit", "quatre-vingt dix neuf")
gros = Array("", "billions", "milliards", "millions", "mille", "dinars", "billion", _
"milliard", "million", "mille", "millimes")
sp = Space(1)
chaine = "00000000000000"
millimes = chiffre * 100 - (Int(chiffre) * 100)
chiffre = Str(Int(chiffre)): lg = Len(chiffre) - 1: chiffre = Right(chiffre, lg): lg = Len(chiffre)
If lg < 15 Then chaine = Mid(chaine, 1, (15 - lg)) Else chaine = ""
chiffre = chaine + chiffre
'billions au centaines
gp = 1
For k = 1 To 5
x = Mid(chiffre, gp, 1): c = a(Val(x))
x = Mid(chiffre, gp + 1, 2): d = a(Val(x))
If k = 5 Then
If t2 <> "" And c & d = "" Then mydz = "dinars" & sp: GoTo fin
If t <> "" And c = "" And d = "un" Then mydz = "un dinars" & sp: GoTo fin
If t <> "" And t2 = "" And c & d = "" Then mydz = "de dinars" & sp: GoTo fin
If t & c & d = "" Then myct = "": mydz = "": GoTo fin
End If
If c & d = "" Then GoTo fin
If d = "" And c <> "" And c <> "un" Then mydz = c & sp & "cents " & gros(k) & sp: GoTo fin
If d = "" And c = "un" Then mydz = "cent " & gros(k) & sp: GoTo fin
If d = "un" And c = "" Then myct = IIf(k = 4, gros(k) & sp, "un " & gros(k + 5) & sp): GoTo fin
If d <> "" And c = "un" Then mydz = "cent" & sp
If d <> "" And c <> "" And c <> "un" Then mydz = c & sp & "cent" + sp
myct = d & sp & gros(k) & sp
fin:
t2 = mydz & myct
t = t & mydz & myct
mydz = "": myct = ""
gp = gp + 3
Next
d = a(millimes)
If t <> "" Then myct = IIf(millime = 1, " millime", " millimes")
If t = "" Then myct = IIf(millime = 1, " millimes", " millimes")
If millimes = 0 Then d = "": myct = ""
chiffrelettre = t & d & myct
End Function
meilleures salutations.
voici le macro :
Function chiffrelettre(chiffre) ' Youky
Dim a As Variant, gros As Variant
a = Array("", "un", "deux", "trois", "quatre", "cinq", "six", "sept", _
"huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix sept", _
"dix huit", "dix neuf", "vingt", "vingt et un", "vingt deux", "vingt trois", "vingt quatre", _
"vingt cinq", "vingt six", "vingt sept", "vingt huit", "vingt neuf", "trente", "trente et un", _
"trente deux", "trente trois", "trente quatre", "trente cinq", "trente six", "trente sept", _
"trente huit", "trente neuf", "quarante", "quarante et un", "quarante deux", "quarante trois", _
"quarante quatre", "quarante cinq", "quarante six", "quarante sept", "quarante huit", _
"quarante neuf", "cinquante", "cinquante et un", "cinquante deux", "cinquante trois", _
"cinquante quatre", "cinquante cinq", "cinquante six", "cinquante sept", "cinquante huit", _
"cinquante neuf", "soixante", "soixante et un", "soixante deux", "soixante trois", _
"soixante quatre", "soixante cinq", "soixante six", "soixante sept", "soixante huit", _
"soixante neuf", "soixante dix", "soixante et onze", "soixante douze", "soixante treize", _
"soixante quatorze", "soixante quinze", "soixante seize", "soixante dix sept", _
"soixante dix huit", "soixante dix neuf", "quatre-vingts", "quatre-vingt un", _
"quatre-vingt deux", "quatre-vingt trois", "quatre-vingt quatre", "quatre-vingt cinq", _
"quatre-vingt six", "quatre-vingt sept", "quatre-vingt huit", "quatre-vingt neuf", _
"quatre-vingt dix", "quatre-vingt onze", "quatre-vingt douze", "quatre-vingt treize", _
"quatre-vingt quatorze", "quatre-vingt quinze", "quatre-vingt seize", "quatre-vingt dix sept", _
"quatre-vingt dix huit", "quatre-vingt dix neuf")
gros = Array("", "billions", "milliards", "millions", "mille", "dinars", "billion", _
"milliard", "million", "mille", "millimes")
sp = Space(1)
chaine = "00000000000000"
millimes = chiffre * 100 - (Int(chiffre) * 100)
chiffre = Str(Int(chiffre)): lg = Len(chiffre) - 1: chiffre = Right(chiffre, lg): lg = Len(chiffre)
If lg < 15 Then chaine = Mid(chaine, 1, (15 - lg)) Else chaine = ""
chiffre = chaine + chiffre
'billions au centaines
gp = 1
For k = 1 To 5
x = Mid(chiffre, gp, 1): c = a(Val(x))
x = Mid(chiffre, gp + 1, 2): d = a(Val(x))
If k = 5 Then
If t2 <> "" And c & d = "" Then mydz = "dinars" & sp: GoTo fin
If t <> "" And c = "" And d = "un" Then mydz = "un dinars" & sp: GoTo fin
If t <> "" And t2 = "" And c & d = "" Then mydz = "de dinars" & sp: GoTo fin
If t & c & d = "" Then myct = "": mydz = "": GoTo fin
End If
If c & d = "" Then GoTo fin
If d = "" And c <> "" And c <> "un" Then mydz = c & sp & "cents " & gros(k) & sp: GoTo fin
If d = "" And c = "un" Then mydz = "cent " & gros(k) & sp: GoTo fin
If d = "un" And c = "" Then myct = IIf(k = 4, gros(k) & sp, "un " & gros(k + 5) & sp): GoTo fin
If d <> "" And c = "un" Then mydz = "cent" & sp
If d <> "" And c <> "" And c <> "un" Then mydz = c & sp & "cent" + sp
myct = d & sp & gros(k) & sp
fin:
t2 = mydz & myct
t = t & mydz & myct
mydz = "": myct = ""
gp = gp + 3
Next
d = a(millimes)
If t <> "" Then myct = IIf(millime = 1, " millime", " millimes")
If t = "" Then myct = IIf(millime = 1, " millimes", " millimes")
If millimes = 0 Then d = "": myct = ""
chiffrelettre = t & d & myct
End Function
A voir également:
- 2 million dinar algérien en lettre
- Un milliard de centimes algérien en chiffre - Meilleures réponses
- 1 milliard de dinar algérien en chiffre - Meilleures réponses
- Difference million milliard - Accueil - Technologies
- Supercopier 2 - Télécharger - Gestion de fichiers
- Telecharger macro convertir chiffre en lettre excel - Télécharger - Tableur
- Clavier iphone chiffre et lettre - Guide
- Télécharger application convertir chiffre en lettre dinars algerien pc - Télécharger - Outils professionnels
1 réponse
Bonjour,
regarde comme cela voir
Function chiffrelettre(chiffre) ' Youky
Dim a As Variant, gros As Variant
a = Array("", "un", "deux", "trois", "quatre", "cinq", "six", "sept", _
"huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix sept", _
"dix huit", "dix neuf", "vingt", "vingt et un", "vingt deux", "vingt trois", "vingt quatre", _
"vingt cinq", "vingt six", "vingt sept", "vingt huit", "vingt neuf", "trente", "trente et un", _
"trente deux", "trente trois", "trente quatre", "trente cinq", "trente six", "trente sept", _
"trente huit", "trente neuf", "quarante", "quarante et un", "quarante deux", "quarante trois", _
"quarante quatre", "quarante cinq", "quarante six", "quarante sept", "quarante huit", _
"quarante neuf", "cinquante", "cinquante et un", "cinquante deux", "cinquante trois", _
"cinquante quatre", "cinquante cinq", "cinquante six", "cinquante sept", "cinquante huit", _
"cinquante neuf", "soixante", "soixante et un", "soixante deux", "soixante trois", _
"soixante quatre", "soixante cinq", "soixante six", "soixante sept", "soixante huit", _
"soixante neuf", "soixante dix", "soixante et onze", "soixante douze", "soixante treize", _
"soixante quatorze", "soixante quinze", "soixante seize", "soixante dix sept", _
"soixante dix huit", "soixante dix neuf", "quatre-vingts", "quatre-vingt un", _
"quatre-vingt deux", "quatre-vingt trois", "quatre-vingt quatre", "quatre-vingt cinq", _
"quatre-vingt six", "quatre-vingt sept", "quatre-vingt huit", "quatre-vingt neuf", _
"quatre-vingt dix", "quatre-vingt onze", "quatre-vingt douze", "quatre-vingt treize", _
"quatre-vingt quatorze", "quatre-vingt quinze", "quatre-vingt seize", "quatre-vingt dix sept", _
"quatre-vingt dix huit", "quatre-vingt dix neuf")
gros = Array("", "billions", "milliards", "millions", "mille", "dinars", "billion", _
"milliard", "million", "mille", "Dinar")
sp = Space(1)
chaine = "00000000000000"
centime = chiffre * 1000 - (Int(chiffre) * 1000)
chiffre = Str(Int(chiffre)): lg = Len(chiffre) - 1: chiffre = Right(chiffre, lg): lg = Len(chiffre)
If lg < 15 Then chaine = Mid(chaine, 1, (15 - lg)) Else chaine = ""
chiffre = chaine + chiffre
'billions au centaines
gp = 1
For k = 1 To 5
x = Mid(chiffre, gp, 1): c = a(Val(x))
x = Mid(chiffre, gp + 1, 2): d = a(Val(x))
If k = 5 Then
If t2 <> "" And c & d = "" Then mydz = "dinars" & sp: GoTo fin
If t <> "" And c = "" And d = "un" Then mydz = "un Dinar" & sp: GoTo fin
If t <> "" And t2 = "" And c & d = "" Then mydz = "de Dinar" & sp: GoTo fin
If t & c & d = "" Then myct = "": mydz = "": GoTo fin
End If
If c & d = "" Then GoTo fin
If d = "" And c <> "" And c <> "un" Then mydz = c & sp & "cent " & gros(k) & sp: GoTo fin
If d = "" And c = "un" Then mydz = "cent " & gros(k) & sp: GoTo fin
If d = "un" And c = "" Then myct = IIf(k = 4, gros(k) & sp, "un " & gros(k + 5) & sp): GoTo fin
If d <> "" And c = "un" Then mydz = "cent" & sp
If d <> "" And c <> "" And c <> "un" Then mydz = c & sp & "cent" + sp
myct = d & sp & gros(k) & sp
fin:
t2 = mydz & myct
t = t & mydz & myct
mydz = "": myct = ""
gp = gp + 3
Next
If centime < 100 Then
d = a(centime)
Else
If Left(centime, 1) = 1 Then d = " cent " & a(Right(centime, 2))
If Left(centime, 1) > 1 Then d = a(Left(centime, 1)) & " cent " & a(Right(centime, 2))
End If
If t <> "" Then myct = IIf(centime = 1, " millime", " millimes")
If t = "" Then myct = IIf(centime = 1, " centime de Dinar", " centimes de Dinar")
If centime = 0 Then d = "": myct = ""
chiffrelettre = t & d & myct
End Function
regarde comme cela voir
Function chiffrelettre(chiffre) ' Youky
Dim a As Variant, gros As Variant
a = Array("", "un", "deux", "trois", "quatre", "cinq", "six", "sept", _
"huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix sept", _
"dix huit", "dix neuf", "vingt", "vingt et un", "vingt deux", "vingt trois", "vingt quatre", _
"vingt cinq", "vingt six", "vingt sept", "vingt huit", "vingt neuf", "trente", "trente et un", _
"trente deux", "trente trois", "trente quatre", "trente cinq", "trente six", "trente sept", _
"trente huit", "trente neuf", "quarante", "quarante et un", "quarante deux", "quarante trois", _
"quarante quatre", "quarante cinq", "quarante six", "quarante sept", "quarante huit", _
"quarante neuf", "cinquante", "cinquante et un", "cinquante deux", "cinquante trois", _
"cinquante quatre", "cinquante cinq", "cinquante six", "cinquante sept", "cinquante huit", _
"cinquante neuf", "soixante", "soixante et un", "soixante deux", "soixante trois", _
"soixante quatre", "soixante cinq", "soixante six", "soixante sept", "soixante huit", _
"soixante neuf", "soixante dix", "soixante et onze", "soixante douze", "soixante treize", _
"soixante quatorze", "soixante quinze", "soixante seize", "soixante dix sept", _
"soixante dix huit", "soixante dix neuf", "quatre-vingts", "quatre-vingt un", _
"quatre-vingt deux", "quatre-vingt trois", "quatre-vingt quatre", "quatre-vingt cinq", _
"quatre-vingt six", "quatre-vingt sept", "quatre-vingt huit", "quatre-vingt neuf", _
"quatre-vingt dix", "quatre-vingt onze", "quatre-vingt douze", "quatre-vingt treize", _
"quatre-vingt quatorze", "quatre-vingt quinze", "quatre-vingt seize", "quatre-vingt dix sept", _
"quatre-vingt dix huit", "quatre-vingt dix neuf")
gros = Array("", "billions", "milliards", "millions", "mille", "dinars", "billion", _
"milliard", "million", "mille", "Dinar")
sp = Space(1)
chaine = "00000000000000"
centime = chiffre * 1000 - (Int(chiffre) * 1000)
chiffre = Str(Int(chiffre)): lg = Len(chiffre) - 1: chiffre = Right(chiffre, lg): lg = Len(chiffre)
If lg < 15 Then chaine = Mid(chaine, 1, (15 - lg)) Else chaine = ""
chiffre = chaine + chiffre
'billions au centaines
gp = 1
For k = 1 To 5
x = Mid(chiffre, gp, 1): c = a(Val(x))
x = Mid(chiffre, gp + 1, 2): d = a(Val(x))
If k = 5 Then
If t2 <> "" And c & d = "" Then mydz = "dinars" & sp: GoTo fin
If t <> "" And c = "" And d = "un" Then mydz = "un Dinar" & sp: GoTo fin
If t <> "" And t2 = "" And c & d = "" Then mydz = "de Dinar" & sp: GoTo fin
If t & c & d = "" Then myct = "": mydz = "": GoTo fin
End If
If c & d = "" Then GoTo fin
If d = "" And c <> "" And c <> "un" Then mydz = c & sp & "cent " & gros(k) & sp: GoTo fin
If d = "" And c = "un" Then mydz = "cent " & gros(k) & sp: GoTo fin
If d = "un" And c = "" Then myct = IIf(k = 4, gros(k) & sp, "un " & gros(k + 5) & sp): GoTo fin
If d <> "" And c = "un" Then mydz = "cent" & sp
If d <> "" And c <> "" And c <> "un" Then mydz = c & sp & "cent" + sp
myct = d & sp & gros(k) & sp
fin:
t2 = mydz & myct
t = t & mydz & myct
mydz = "": myct = ""
gp = gp + 3
Next
If centime < 100 Then
d = a(centime)
Else
If Left(centime, 1) = 1 Then d = " cent " & a(Right(centime, 2))
If Left(centime, 1) > 1 Then d = a(Left(centime, 1)) & " cent " & a(Right(centime, 2))
End If
If t <> "" Then myct = IIf(centime = 1, " millime", " millimes")
If t = "" Then myct = IIf(centime = 1, " centime de Dinar", " centimes de Dinar")
If centime = 0 Then d = "": myct = ""
chiffrelettre = t & d & myct
End Function