ConvNumLetter




Function LETTEURO(StrEuro, Tipe As Variant) As String

'Nota: per funzionare bisogna linkare anche la

'funzione per convertire un valore numerico in

'Lire (Lettere)


Dim T As Currency, D1, D2, K, q, U, H, Centesimi As String
If ((Int((StrEuro - (Int(StrEuro))))) - StrEuro) < 0 Then T = Int((StrEuro - (Int(StrEuro))) * 100) Else T = 0
LETTEURO = Lettere(Int(StrEuro), 1)
K = Len(T)
Centesimi = ""

D1 = Right(T, 1)
If T > 9 Then D2 = Mid(T, 1, 1) Else D2 = ""

GoTo Iniziamo
cifraA:
If q = "1" Then U = "uno"
If q = "2" Then U = "due"
If q = "3" Then U = "tre"
If q = "4" Then U = "quattro"
If q = "5" Then U = "cinque"
If q = "6" Then U = "sei"
If q = "7" Then U = "sette"
If q = "8" Then U = "otto"
If q = "9" Then U = "nove"
If q = "0" Then U = ""
Return

cifraB:

If q = "2" And H = "1" Then U = "vent"
If q = "2" And H = "8" Then U = "vent"
If U = "" And q = "2" Then U = "venti"

If q = "3" And H = "1" Then U = "trent"
If q = "3" And H = "8" Then U = "trent"
If U = "" And q = "3" Then U = "trenta"

If q = "4" And H = "1" Then U = "quarant"
If q = "4" And H = "8" Then U = "quarant"
If U = "" And q = "4" Then U = "quaranta"

If q = "5" And H = "1" Then U = "cinquant"
If q = "5" And H = "8" Then U = "cinquant"
If U = "" And q = "5" Then U = "cinquanta"

If q = "6" And H = "1" Then U = "sessant"
If q = "6" And H = "8" Then U = "sessant"
If U = "" And q = "6" Then U = "sessanta"

If q = "7" And H = "1" Then U = "settant"
If q = "7" And H = "8" Then U = "settant"
If U = "" And q = "7" Then U = "settanta"

If q = "8" And H = "1" Then U = "ottant"
If q = "8" And H = "8" Then U = "ottant"
If U = "" And q = "8" Then U = "ottanta"

If q = "9" And H = "1" Then U = "novant"
If q = "9" And H = "8" Then U = "novant"
If U = "" And q = "9" Then U = "novanta"

If q = "0" Then U = ""
Return
Decine0:
If H = "0" Then U = "dieci"
If H = "1" Then U = "undici"
If H = "2" Then U = "dodici"
If H = "3" Then U = "tredici"
If H = "4" Then U = "quattordici"
If H = "5" Then U = "quindici"
If H = "6" Then U = "sedici"
If H = "7" Then U = "diciassette"
If H = "8" Then U = "diciotto"
If H = "9" Then U = "diciannove"
Return


Iniziamo:
'unita

q = D1: GoSub cifraA: D1 = U: U = "": q = ""

'decine

q = D2
H = Right(T, 1)
If q = "1" Then GoSub Decine0 Else GoSub cifraB
If q = "1" Then D1 = ""
D2 = U
U = "": q = ""



fine1:
If D1 = "" And D2 = "" Then D1 = "ZERO"
LETTEURO = LETTEURO + Chr(128) + D2 + D1 + Chr(162)
If Tipe = 1 Then LETTEURO = StrConv(LETTEURO, vbUpperCase)
If Tipe = 2 Then LETTEURO = StrConv(LETTEURO, vbLowerCase)
If Tipe = 3 Then LETTEURO = StrConv(LETTEURO, vbProperCase)
End Function










( convnumletter.html )- by Paolo Puglisi - Modifica del 17/12/2023