la suite du module:
Private Function ConvNumCent(Nombre As Long, Langue As Long) As String
Dim TabUnit As Variant
Dim lCent As Long, lReste As Long
Dim strReste As String
TabUnit = Array("", "un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf", "dix")
lCent = Int(Nombre / 100)
lReste = Nombre - (lCent * 100)
strReste = ConvNumDizaine(lReste, Langue, False)
Select Case lCent
Case 0
ConvNumCent = strReste
Case 1
If lReste = 0 Then
ConvNumCent = "cent"
Else
ConvNumCent = "cent " & strReste
End If
Case Else
If lReste = 0 Then
ConvNumCent = TabUnit(lCent) & " cents"
Else
ConvNumCent = TabUnit(lCent) & " cent " & strReste
End If
End Select
End Function
Private Function ConvNumDizaine(Nombre As Long, Langue As Long, bDec As Boolean) As String
Dim TabUnit As Variant, TabDiz As Variant
Dim lUnit As Long, lDiz As Long
Dim strLiaison As String
Select Case Dev
Case 0 To 3
If bDec Then
TabDiz = Array("zéro", "", "vingt", "trente", "quarante", "cinquante", _
"soixante", "soixante", "quatre-vingt", "quatre-vingt")
Else
TabDiz = Array("", "", "vingt", "trente", "quarante", "cinquante", _
"soixante", "soixante", "quatre-vingt", "quatre-vingt")
End If
Case 4
If bDec Then
TabDiz = Array("zéro", "", "vingt", "trente", "quarante", "cinquante", _
"soixante", "soixante-dix", "quatre-vingt", "quatre-vingt-dix")
Else
TabDiz = Array("", "", "vingt", "trente", "quarante", "cinquante", _
"soixante", "soixante-dix", "quatre-vingt", "quatre-vingt-dix")
End If
End Select
If Nombre = 0 Then
TabUnit = Array("zéro")
Else
TabUnit = Array("", "un", "deux", "trois", "quatre", "cinq", "six", "sept", _
"huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", _
"seize", "dix-sept", "dix-huit", "dix-neuf")
End If
If Langue = 1 Then
TabDiz(7) = "septante"
TabDiz(9) = "nonante"
ElseIf Langue = 2 Then
TabDiz(7) = "septante"
TabDiz(8) = "huitante"
TabDiz(9) = "nonante"
End If
lDiz = Int(Nombre / 10)
lUnit = Nombre - (lDiz * 10)
strLiaison = "-"
If lUnit = 1 Then strLiaison = " et "
Select Case lDiz
Case 0
strLiaison = " "
Case 1
lUnit = lUnit + 10
strLiaison = ""
Case 7
If Langue = 0 Then lUnit = lUnit + 10
Case 8
If Langue <> 2 Then strLiaison = "-"
Case 9
If Langue = 0 Then
lUnit = lUnit + 10
strLiaison = "-"
End If
End Select
ConvNumDizaine = TabDiz(lDiz)
If lDiz = 8 And Langue <> 2 And lUnit = 0 Then ConvNumDizaine = ConvNumDizaine & "s"
If TabUnit(lUnit) <> "" Then
ConvNumDizaine = ConvNumDizaine & strLiaison & TabUnit(lUnit)
Else
ConvNumDizaine = ConvNumDizaine
End If
End Function
Private Function ConvNumEnt(Nombre As Double, Langue As Long)
Dim Tmp As Double, dblReste As Double
Dim strTmp As String
Dim iCent As Long, iMille As Long, iMillion As Long
Dim iMilliard As Long, iBillion As Long
Tmp = Nombre - (Int(Nombre / 1000) * 1000)
iCent = CInt(Tmp)
ConvNumEnt = Nz(ConvNumCent(iCent, Langue))
dblReste = Int(Nombre / 1000)
If Tmp = 0 And dblReste = 0 Then Exit Function
Tmp = dblReste - (Int(dblReste / 1000) * 1000)
If Tmp = 0 And dblReste = 0 Then Exit Function
iMille = CInt(Tmp)
strTmp = ConvNumCent(iMille, Langue)
Select Case Tmp
Case 0
Case 1
strTmp = " mille "
Case Else
strTmp = strTmp & " mille "
End Select
If iMille = 0 And iCent > 0 Then ConvNumEnt = "et " & ConvNumEnt
ConvNumEnt = Nz(strTmp) & ConvNumEnt
dblReste = Int(dblReste / 1000)
Tmp = dblReste - (Int(dblReste / 1000) * 1000)
If Tmp = 0 And dblReste = 0 Then Exit Function
iMillion = CInt(Tmp)
strTmp = ConvNumCent(iMillion, Langue)
Select Case Tmp
Case 0
Case 1
strTmp = strTmp & " million "
Case Else
strTmp = strTmp & " millions "
End Select
If iMille = 1 Then ConvNumEnt = "et " & ConvNumEnt
ConvNumEnt = Nz(strTmp) & ConvNumEnt
dblReste = Int(dblReste / 1000)
Tmp = dblReste - (Int(dblReste / 1000) * 1000)
If Tmp = 0 And dblReste = 0 Then Exit Function
iMilliard = CInt(Tmp)
strTmp = ConvNumCent(iMilliard, Langue)
Select Case Tmp
Case 0
Case 1
strTmp = strTmp & " milliard "
Case Else
strTmp = strTmp & " milliards "
End Select
If iMillion = 1 Then ConvNumEnt = "et " & ConvNumEnt
ConvNumEnt = Nz(strTmp) & ConvNumEnt
dblReste = Int(dblReste / 1000)
Tmp = dblReste - (Int(dblReste / 1000) * 1000)
If Tmp = 0 And dblReste = 0 Then Exit Function
iBillion = CInt(Tmp)
strTmp = ConvNumCent(iBillion, Langue)
Select Case Tmp
Case 0
Case 1
strTmp = strTmp & " billion "
Case Else
strTmp = strTmp & " billions "
End Select
If iMilliard = 1 Then ConvNumEnt = "et " & ConvNumEnt
ConvNumEnt = Nz(strTmp) & ConvNumEnt
End Function
Private Function Nz(strNb As String) As String
If strNb <> " zéro" Then Nz = strNb
End Function