Un esempio classico di problema che può essere risolto scrivendo una funzione è quello di trasformare un numero scritto in cifre nel corrispondente testo in lettere. E' anche un esempio di una di quelle funzione che fa sempre comodo avere e che può essere insierita in un raccoglitore unico.
La funzione non è semplicissima da leggere, deve tenere conto dei molti casi del plurale e singolare per i numeri.
Per prima cosa una sotto-fuznione che ci permette di avere il testo dei numeri da 1 a 19, è anche un buon esempio di come si possano utilizzare i 
vettori per migliorare la leggibilità del codice. E' definita "privata" ovvero non visibile fuori dal modulo.
Private Function TestoCifra(
Cifra As Long) 
As String
  Testo = 
Array("zero", "uno", "due", "tre", "quattro", "cinque", "sei", "sette", "otto", "nove", "dieci", _
                "undici", "dodici", "tredici", "quattordici", "quindici", "sedici", "diciassette", "diciotto", "diciannove")
  
TestoCifra = Testo(
Cifra)
End Function 
Private Function TestoDecina(
Decina As Long, 
Unita As Integer) 
As String
  Testo1 = 
Array("", "", "venti", "trenta", "quaranta", "cinquanta", "sessanta", "settanta", "ottanta", "novanta", "cento")
  Testo2 = 
Array("", "", "vent", "trent", "quarant", "cinquant", "sessant", "settant", "ottant", "novant", "cento")
  
  
If (
Unita = 1 Or 
Unita = 8) 
Then
    TestoDecina = Testo2(
Decina / 10)
  
Else
    TestoDecina = Testo1(
Decina / 10)
  
End If
End Function 
Function ValoreInLettere(
Valore As Long) 
As String
  Dim res 
As String
    
  Select Case Valore
    Case Is < 20
      res = TestoCifra(
Valore)
    
Case Is < 101
      
If (Round(
Valore / 10) * 10) = 
Valore Then
        res = TestoDecina(
Valore , 0)
      
Else
        res = TestoDecina(Round((
Valore - 5) / 10) * 10, 
Valore - Round((
Valore - 5) / 10, 0) * 10) & 
ValoreInLettere(Valore- Round((Valore- 5) / 10, 0) * 10)
      
End If
    
    Case Is < 200
      res = "cento" & 
ValoreInLettere(
Valore - 100)
    
Case Is < 1000
      
If Round(
Valore / 100) * 100 = 
Valore Then
        res = 
ValoreInLettere(
Valore / 100) & "cento"
      
Else
        res = 
ValoreInLettere(Round((Valore- 50) / 100)) & "cento" & 
ValoreInLettere(Valore- Round((Valore- 50) / 100) * 100)
      
End If
    
    Case 1000
      res = "mille"
    
Case Is < 2000
      res = "mille" & 
ValoreInLettere(
Valore - 1000)
    
Case Is < 1000000
      
If Round(
Valore / 1000) * 1000 = 
Valore Then
        res = 
ValoreInLettere(Valore/ 1000) & "mila"
      
Else
        res = 
ValoreInLettere(Round((
Valore - 500) / 1000)) & "mila" & 
ValoreInLettere(
Valore - Round((
Valore - 500) / 1000) * 1000)
      
End If
    
    Case 1000000
      res = "unmilione"
    
Case Is < 2000000
      res = "unmilione" & 
ValoreInLettere(Valore- Round((Valore- 500000) / 1000000) * 1000000)
    
Case Is < 1000000000
      
If Round(
Valore / 1000000) * 1000000 = 
Valore Then
        res = 
ValoreInLettere(Valore/ 1000000) & "milioni"
      
Else
        res = 
ValoreInLettere(Round((Valore- 500000) / 1000000)) & "milioni" & 
ValoreInLettere(Valore- Round((Valore- 500000) / 1000000) * 1000000)
      
End If
    
    Case 1000000000
      res = "unmiliardo"
    
Case Is < 2000000000
      res = "unmiliardo" & 
ValoreInLettere(
Valore - Round((
Valore - 500000) / 1000000) * 1000000)
    
Case Is < 1E+15
      
If Round(
Valore / 1000000000) * 1000000000 = 
Valore Then
        res = 
ValoreInLettere(
Valore / 1000000000) & "miliardi"
      
Else
        res = 
ValoreInLettere(Round((
Valore - 500000000) / 1000000000)) & "miliardi" & 
ValoreInLettere(
Valore - Round((
Valore - 500000000) / 1000000000) * 1000000000)
      
End If
  End Select
  ValoreInLettere = res
End Function