Private Sub Command1_Click()
MsgBox Cant_2_Letra(Val(Text1.Text))
End Sub
Private Function Cant_2_Letra(cantidad As Integer) As String
Dim PonUnidades As Boolean
Dim Resultado As String
Dim centenas As Integer
Dim decenas As Integer
Dim unidades As Integer
Resultado = ""
centenas = Int(cantidad / 100)
decenas = Int((cantidad Mod 100) / 10)
unidades = cantidad Mod 10
Select Case cantidad
Case 100
Resultado = "CIEN "
Case 1
Resultado = "UN "
Case Else
Select Case centenas
Case 1
Resultado = "CIENTO "
Case 2
Resultado = "DOCIENTOS "
Case 3
Resultado = "TRECIENTOS "
Case 4
Resultado = "CUATROCIENTOS "
Case 5
Resultado = "QUINIENTOS "
Case 6
Resultado = "SEISCIENTOS "
Case 7
Resultado = "SETECIENTOS "
Case 8
Resultado = "OCHOCIENTOS "
Case 9
Resultado = "NOVECIENTOS "
End Select
PonUnidades = unidades <> 0
Select Case decenas
Case 1
PonUnidades = False
Select Case unidades
Case 0
Resultado = Resultado + "DIEZ "
Case 1
Resultado = Resultado + "ONCE "
Case 2
Resultado = Resultado + "DOCE "
Case 3
Resultado = Resultado + "TRECE "
Case 4
Resultado = Resultado + "CATORCE "
Case 5
Resultado = Resultado + "QUINCE "
Case Else
Resultado = Resultado + "DIECI"
PonUnidades = True
End Select
Case 2
Select Case unidades
Case 0
Resultado = Resultado + "VEINTE "
PonUnidades = False
Case Else
Resultado = Resultado + "VEINTI"
End Select
Case 3
Resultado = Resultado + "TREINTA "
Case 4
Resultado = Resultado + "CUARENTA "
Case 5
Resultado = Resultado + "CINCUENTA "
Case 6
Resultado = Resultado + "SESENTA "
Case 7
Resultado = Resultado + "SETENTA "
Case 8
Resultado = Resultado + "OCHENTA "
Case 9
Resultado = Resultado + "NOVENTA "
End Select
If decenas > 2 And PonUnidades Then
Resultado = Resultado + "Y "
End If
If PonUnidades Then
Select Case unidades
Case 1
Resultado = Resultado + "UN "
Case 2
Resultado = Resultado + "DOS "
Case 3
Resultado = Resultado + "TRES "
Case 4
Resultado = Resultado + "CUATRO "
Case 5
Resultado = Resultado + "CINCO "
Case 6
Resultado = Resultado + "SEIS "
Case 7
Resultado = Resultado + "SIETE "
Case 8
Resultado = Resultado + "OCHO "
Case 9
Resultado = Resultado + "NUEVE "
End Select
End If
End Select
Cant_2_Letra = Resultado
End Function