VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Check this out, Currency Converter in one procedure only... You don't need many procedures...

by Mr. TGM-Programmer, Balayan, Batangas, Philippines (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 31st July 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Check this out, Currency Converter in one procedure only... You don't need many procedures...

API Declarations


Dim WORDVAR, intgr, DECI, _
Ones(19), Tens(9), Thou(4) As String
Dim ictr, chars, charCntr As Integer



Rate Check this out, Currency Converter in one procedure only... You don't need many procedures...



WORDVAR = ""
If Not IsNumeric(Text1) Then
    Text1.SetFocus
    Text1 = ""
    MsgBox "Sorry, your entry is not numeric, entry is not valid"
    Exit Sub
Else
    Text1 = Format(Text1, "#0.000")
End If

chars = Format(Trim(Text1), "000")
charCntr = Len(chars)

If charCntr > 12 Then
    Text1.SetFocus
    Text1 = ""
    MsgBox "Entry out of range..."
    Exit Sub
End If

If Len(Trim(Text1)) = 0 Then
    msgbox( "Zero",vbok,"Result by Mr. TGM")
    Exit Sub
End If

Ones(1) = "One"
Ones(2) = "Two"
Ones(3) = "Three"
Ones(4) = "Four"
Ones(5) = "Five"
Ones(6) = "Six"
Ones(7) = "Seven"
Ones(8) = "Eight"
Ones(9) = "Nine"
Ones(10) = "Ten"
Ones(11) = "Eleven"
Ones(12) = "Twelve"
Ones(13) = "Thirteen"
Ones(14) = "Fourteen"
Ones(15) = "Fifteen"
Ones(16) = "Sixteen"
Ones(17) = "Seventeen"
Ones(18) = "Eighteen"
Ones(19) = "Nineteen"

Tens(1) = "Ten"
Tens(2) = "Twenty"
Tens(3) = "Thirty"
Tens(4) = "Fourty"
Tens(5) = "Fifty"
Tens(6) = "Sixty"
Tens(7) = "Seventy"
Tens(8) = "Eighty"
Tens(9) = "Ninety"

Thou(3) = "Thousand "
Thou(2) = "Million "
Thou(1) = "Billion "
Thou(4) = ""

intgr = RTrim(LTrim(Str(Text1)))

If InStr(intgr, ".") <> 0 Then
    intgr = Left(intgr, InStr(intgr, ".") - 1)
End If

intgr = Right("000000000000" & intgr, 12)
ictr = 3

For ictr = 1 To 12 Step 3
    DECI = Mid(intgr, ictr, 3)
    
    If DECI <> "000" Then
        If Left(DECI, 1) <> "0" Then
            WORDVAR = WORDVAR & Ones(Val(Left(DECI, 1))) & " Hundred"
        End If
    
        If Val(Right(DECI, 2)) <= 19 Then
            WORDVAR = WORDVAR & " " & Ones(Val(Right(DECI, 2))) & ""
        Else
            WORDVAR = WORDVAR & " " & Tens(Val(Mid(DECI, 2, 1))) & " " & Ones(Val(Right(DECI, 1))) & ""
        End If
        WORDVAR = WORDVAR & " " & Thou((ictr - 1) / 3 + 1) & ""
    End If
Next

intgr = RTrim(LTrim(Str(Text1)))
If InStr(intgr, ".") <> 0 Then
    DECI = Right(intgr, (Len(intgr) - InStr(intgr, ".")))
    DECI = "." + DECI
    DECI = Format(DECI, ".00")
    DECI = Mid(DECI, 2, 2)
Else
    DECI = "00"
End If

msgbox (WORDVAR & IIf(Val(DECI) > 0, "& " & Left(DECI & "00", 2) & "/100", "") & " Only.", vbokonly, "Result by Mr. TGM")
Text1.SetFocus
Text1 = Format(Text1, "0,00.000")

End Sub


If you wish to thank me, just feel free to email me. 


Download this snippet    Add to My Saved Code

Check this out, Currency Converter in one procedure only... You don't need many procedures... Comments

No comments have been posted about Check this out, Currency Converter in one procedure only... You don't need many procedures.... Why not be the first to post a comment about Check this out, Currency Converter in one procedure only... You don't need many procedures....

Post your comment

Subject:
Message:
0/1000 characters