Question : Money currency translated into word for check in VB6 and .NET 2005

We are looking for a solution or a function or routing where we can translate a currency check amount into words.  For example:

$10,953.91  in letters/words, would be:

Ten Thousand Nine Hundred fifty three with 91/100

We looking for English and Spanish...

Whats the best way in doing this?

Answer : Money currency translated into word for check in VB6 and .NET 2005

the code is correct ....put the namespace iittially and after End sub of your form laod event copy it and paste it ...it works
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
    Dim oneWords As String = ",One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten,Eleven,Twelve,Thirteen,Fourteen,Fifteen,Sixteen,Seventeen,Eighteen,Nineteen"
    Dim ones() As String = oneWords.Split(",")
    Dim tenWords As String = ",Ten,Twenty,Thirty,Forty,Fifty,Sixty,Seventy,Eighty,Ninety"
    Dim tens() As String = tenWords.Split(",")

    Private Function Convert(ByVal input As String) As String
        input = input.Replace("$", "").Replace(",", "")
        If input.Length > 12 Then Return "Error in input value"
        Dim output, dollars, mills, thous, hunds, cents As String
        Dim mill, thou, hund, cent As Integer
        If input.IndexOf(".") > 0 Then
            dollars = input.Substring(0, input.IndexOf(".")).PadLeft(9, "0")
            cents = input.Substring(input.IndexOf(".") + 1).PadRight(2, "0")
            If cents = "00" Then cents = "0"
        Else
            dollars = input.PadLeft(9, "0") : cents = "0"
        End If
        mill = CType(dollars.Substring(0, 3), Integer) : mills = convertHundreds(mill)
        thou = CType(dollars.Substring(3, 3), Integer) : thous = convertHundreds(thou)
        hund = CType(dollars.Substring(6, 3), Integer) : hunds = convertHundreds(hund)
        cent = CType(cents, Integer) : cents = convertHundreds(cent)
        output = IIf(mills.Trim = "", "", mills + " Million ")
        output += IIf(thous.Trim = "", "", thous + " Thousand ")
        output += IIf(hunds.Trim = "", "", hunds)
        output = IIf(output.Length = 0, "Zero Dollars and ", output + " Dollars and ")
        output = IIf(output = "One Dollars and ", "One Dollar and ", output)
        output += IIf(cents = "", "Zero", cents) + " Cents"
        Return output
    End Function

    Private Function convertHundreds(ByVal input As Integer) As String
        Dim output As String
        If input <= 99 Then
            output = (convertTens(input))
        Else
            output = ones(Floor(input / 100))
            output += " Hundred "
            If input - Floor(input / 100) * 100 = 0 Then
                output += ""
            Else
                output += "" + convertTens(input - Floor(input / 100) * 100)
            End If
        End If
        Return output
    End Function

    Private Function convertTens(ByVal input As Integer) As String
        Dim output As String
        If input < 20 Then
            output = ones(input)
            input = 0
        Else
            output = tens(CType(Floor(input / 10), Integer))
            input -= Floor(input / 10) * 10
        End If
        output = output + IIf(ones(input).Trim = "", "", "-" + ones(input))
        Return output
    End Function
Random Solutions  
 
programming4us programming4us