0% found this document useful (0 votes)
42 views2 pages

Convert Numbers to French Text

This document contains code for a VBA macro that converts numeric values to their textual representations in French. It defines functions for converting individual digits, teens, tens, hundreds, thousands, and millions to French text. The main nombre2texte function takes a numeric value as input, checks its range, and calls the appropriate conversion function to output the French text representation.

Uploaded by

ddqq9005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views2 pages

Convert Numbers to French Text

This document contains code for a VBA macro that converts numeric values to their textual representations in French. It defines functions for converting individual digits, teens, tens, hundreds, thousands, and millions to French text. The main nombre2texte function takes a numeric value as input, checks its range, and calls the appropriate conversion function to output the French text representation.

Uploaded by

ddqq9005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Public Sub nombre2texte()

n = ActiveCell.Value
If n = 0 Then
result = "z�ro"
ElseIf n < 100 Then
result = cent(n)
ElseIf n < 1000 Then
result = mille(n)
ElseIf n < 1000000 Then
result = million(n)
ElseIf n < 1000000000 Then
result = mille(Int(n / 1000000)) & " million " & million(n Mod 1000000)
Else
result = "D�passement de capacit� >100"
End If
ActiveCell.Offset(0, 1) = result
End Sub

Public Function unite(u)


Select Case (u)
Case 1: unite = "un"
Case 2: unite = "deux"
Case 3: unite = "trois"
Case 4: unite = "quatre"
Case 5: unite = "cinq"
Case 6: unite = "six"
Case 7: unite = "sept"
Case 8: unite = "huit"
Case 9: unite = "neuf"
End Select
End Function

Public Function vingt(v)


Select Case (v)
Case 10: vingt = "dix"
Case 11: vingt = "onze"
Case 12: vingt = "douze"
Case 13: vingt = "treize"
Case 14: vingt = "quatorze"
Case 15: vingt = "quinze"
Case 16: vingt = "seize"
Case 17: vingt = "dix-sept"
Case 18: vingt = "dix-huit"
Case 19: vingt = "dix-neuf"
End Select
End Function

Public Function dizaine(d)


Select Case (d)
Case 2: dizaine = "vingt"
Case 3: dizaine = "trente"
Case 4: dizaine = "quaronte"
Case 5: dizaine = "cinquante"
Case 6: dizaine = "soixante"
Case 8: dizaine = "quatre-vingt"
End Select
End Function
Public Function cent(n)
If n < 10 Then
cent = unite(n)
ElseIf n < 20 Then
cent = vingt(n)
ElseIf n < 70 Or n >= 80 And n < 90 Then
cent = dizaine(Int(n / 10)) & " " & unite(n Mod 10)
ElseIf n >= 70 And n < 80 Or n >= 90 And n < 100 Then
cent = dizaine(Int(n / 10) - 1) & " " & vingt((n Mod 10) + 10)
End If
End Function

Public Function mille(n)


If Int(n / 100) = 0 Then
mille = cent(n Mod 100)
ElseIf Int(n / 100) = 1 Then
mille = "cent " & cent(n Mod 100)
ElseIf n Mod 100 = 0 Then
mille = unite(Int(n / 100)) & " cents"
Else
mille = unite(Int(n / 100)) & " cent " & cent(n Mod 100)
End If
End Function

Public Function million(n)


If Int(n / 1000) = 0 Then
million = mille(n Mod 1000)
ElseIf Int(n / 1000) = 1 Then
million = "mille " & mille(n Mod 1000)
Else
million = mille(Int(n / 1000)) & " mille " & mille(n Mod 1000)
End If
End Function

You might also like