VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Number to text conversion currency to word conversion Number to word conversion Number to word conv

by Riyas Palakkat (3 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Sat 28th July 2007
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Number to text conversion currency to word conversion Number to word conversion Number to word conversion in Million format

API Declarations


Option Explicit
Dim Ones(), Tens(), Hundreds()
'Add a text box named text1 and a command button named command1

Rate Number to text conversion currency to word conversion Number to word conversion Number to word conv



Private Sub Command1_Click()
    Ones() = Array("", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen")
    Tens() = Array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety")
    'Hundreds = Array("One hundred", "hundred", "Three hundred", "Four hundred", "Five hundred", "Six hundred", "Seven hundred", "Eight hundred", "Nine hundred")
    MsgBox toNum(Val(Format(Text1.Text, "0.00")))
End Sub
'-------------------------------------------------

Public Function toNum(Num As Long) As String
    Dim NumPos As Long, TxtData As String
    NumPos = Num \ 1000000
    If NumPos > 0 Then '
        TxtData = toNum(NumPos) & " Million"
        Num = Num Mod 1000000
    ElseIf Num \ 100000 > 0 Then
        NumPos = Num \ 100000
        TxtData = toNum(NumPos) & " Hundred "
        Num = Num Mod 100000
    ElseIf Num \ 1000 > 0 Then
        NumPos = Num \ 1000
        TxtData = toNum(NumPos) & " Thousand"
        Num = Num Mod 1000
    ElseIf Num \ 100 > 0 Then
        NumPos = Num \ 100
        TxtData = toNum(NumPos) & " Hundred"
        Num = Num Mod 100
    ElseIf Num >= 20 Then
        TxtData = Tens(Num \ 10) & " " & Ones(Num Mod 10)
        Num = 0
    Else
        TxtData = Ones(Num)
        Num = 0
    End If
    If Num > 0 Then
        'toNum = toNum(Num) & " " & TxtData
        toNum = TxtData & " " & toNum(Num)
    Else
        toNum = TxtData
    End If
End Function

Private Sub Text1_Validate(Cancel As Boolean)
    Text1.Text = Format(Text1.Text, "#,###,##0.00")
End Sub

Download this snippet    Add to My Saved Code

Number to text conversion currency to word conversion Number to word conversion Number to word conv Comments

No comments have been posted about Number to text conversion currency to word conversion Number to word conversion Number to word conv. Why not be the first to post a comment about Number to text conversion currency to word conversion Number to word conversion Number to word conv.

Post your comment

Subject:
Message:
0/1000 characters