Chiffre vers lettre

petiflamand Messages postés 674 Date d'inscription samedi 31 mai 2003 Statut Membre Dernière intervention 26 mai 2013 - 18 déc. 2004 à 09:52
flowres Messages postés 2 Date d'inscription jeudi 20 août 2009 Statut Membre Dernière intervention 19 février 2010 - 16 sept. 2009 à 03:46
Salut je veux convertire des chiffres vers des lettre

donc 100 -->cent
1000.25 --> mille virgule vingt cinq
Quelq'un peu m'aider
Merci
c'est asser urgent

3 réponses

cs_rene38 Messages postés 1858 Date d'inscription samedi 29 juin 2002 Statut Membre Dernière intervention 17 octobre 2013 11
18 déc. 2004 à 10:35
Bonjour

Public Function Francise(ByVal nb As String) As String
Do While Left(nb, 1) = "0"    If Left(nb, 1) "0" Then nb Mid(nb, 2) 'suppression des zéros à gauche
Loop
Select Case Len(nb)
    Case 0
        Francise = ""
    Case 1
    Select Case nb
        Case "0": Francise = "zéro"
        Case "1": Francise = "un"
        Case "2": Francise = "deux"
        Case "3": Francise = "trois"
        Case "4": Francise = "quatre"
        Case "5": Francise = "cinq"
        Case "6": Francise = "six"
        Case "7": Francise = "sept"
        Case "8": Francise = "huit"
        Case "9": Francise = "neuf"
    End Select
    Case 2
        Select Case nb
            Case "10": Francise = "dix"
            Case "11": Francise = "onze"
            Case "12": Francise = "douze"
            Case "13": Francise = "treize"
            Case "14": Francise = "quatorze"
            Case "15": Francise = "quinze"
            Case "16": Francise = "seize"
            Case "17" To "19": Francise = "dix " & Francise(Right(nb, 1))
            Case "20" To "29": Francise = "vingt " & Francise(Right(nb, 1))
            Case "30" To "39": Francise = "trente " & Francise(Right(nb, 1))
            Case "40" To "49": Francise = "quarante " & Francise(Right(nb, 1))
            Case "50" To "59": Francise = "cinquante " & Francise(Right(nb, 1))
            Case "60" To "69": Francise = "soixante " & Francise(Right(nb, 1))
            Case "70" To "79"
                nb = Format(Val(nb) - 60, "##")
                Francise = "soixante " & Francise(nb)                If Right(Francise, 4) "onze" Then Francise "soixante et onze"
            Case "80": Francise = "quatre-vingts"
            Case "81" To "99"
                nb = Format(Val(nb) - 80, "##")
                Francise = "quatre-vingt " & Francise(nb)
        End Select        If Right(Francise, 2) "un" And nb > "20" And nb < 70 Then Francise Left(Francise, Len(Francise) - 2) & "et un"
                If Right(Francise, 4) "zéro" Then Francise Left(Francise, Len(Francise) - 5)
    Case 3
        Select Case Left(nb, 1)
            Case "1": Francise = "cent " & Francise(Mid(nb, 2))
            Case Else
                Francise = Francise(Left(nb, 1)) & " cent " & Francise(Mid(nb, 2))                If Right(Francise, 6) " cent " Then Francise Left(Francise, Len(Francise) - 1) & "s"
        End Select
    Case 4 To 6
        Francise = Francise(Left(nb, Len(nb) - 3)) & " mille " & Francise(Right(nb, 3))        If Left(Francise, 2) "un" Then Francise Mid(Francise, 4)
    Case 7 To 9
        Francise = Francise(Left(nb, Len(nb) - 6)) & " millions " & Francise(Right(nb, 6))        If Left(Francise, 2) "un" Then Francise Left(Francise, 10) & Mid(Francise, 12)
    Case 10 To 12
        Francise = Francise(Left(nb, Len(nb) - 9)) & " milliards " & Francise(Right(nb, 9))        If Left(Francise, 2) "un" Then Francise Left(Francise, 11) & Mid(Francise, 13)
    Case Else
End Select
End Function
'-------------------------------------------------------------------
Public Function Nombre_en_lettres(ByVal nb As String) As String
Dim Affichage As String, Entier As String, Décimal As String
nb = Replace(nb, ".", ",") '<- à supprimer selon paramètres régionaux
If Not IsNumeric(nb) Then
    MsgBox nb & " n'est pas un nombre", vbCritical, Erreur
    Exit Function
End If
If InStr(nb, ",") = 0 Then 'c'est un entier
    Affichage = Francise(nb)
Else 'c'est un décimal
    Do While Right(nb, 1) = "0" 'suppression des zéros à droite de la partie décimale        If Right(nb, 1) "0" Then nb Left(nb, Len(nb) - 1)
    Loop
    Entier = Francise(Left(nb, InStr(nb, ",") - 1))
    If Entier = "un" Then
        Entier = Entier & " euro "
    Else
         If Entier <> "" Then
            Entier = Entier & " euros "
        End If
    End If    If Len(Mid(nb, InStr(nb, ",") + 1)) 1 Then nb nb & "0" '2 décimales
    Décimal = Francise(Mid(nb, InStr(nb, ",") + 1))
    Affichage = Entier & Décimal
    If Décimal <> "" Then
         Affichage = Affichage & " " & "centime"
        If Décimal <> "un" Then Affichage = Affichage & "s"
    End If
End If
Nombre_en_lettres = Affichage ' retour fonction
End Function


Mettre les 2 fonctions dans un module.
Nombre_en_lettres("1000.25") renvoie
mille euros vingt cinq centimes
0
petiflamand Messages postés 674 Date d'inscription samedi 31 mai 2003 Statut Membre Dernière intervention 26 mai 2013 1
18 déc. 2004 à 10:48
Merci beaucoup grave a vous j'ai terminé mon programme de facturation pour une station service

Merci encore
0
flowres Messages postés 2 Date d'inscription jeudi 20 août 2009 Statut Membre Dernière intervention 19 février 2010
16 sept. 2009 à 03:46
aprés Plus que 4 ans j'utilise ce code et il marche encore en access 2007
je suis reconnaissante rene 38
0
Rejoignez-nous