Question convert a number to equivalent word?

weakinvbdotnet

New member
Joined
Jul 21, 2009
Messages
1
Programming Experience
Beginner
hello guys....
i am college student taking vb.net subject
i have a problem big problem so i need somebody to help me
my problem is :
write a program convert a number to equivalent word
example
enter a number:123
One hundred twenty three
my programs is works i
but the problem is use only nested if


thanks...;)
i need also video tutorial in vb.net
 
Hello.

Though, you're hard to understand I might know what you want. You'll have to parse the number...something like:
VB.NET:
Imports System.Convert

    Private Function parseNumberToWords(ByVal number As Integer) As String
        Dim numberAsString As String = number.ToString()
        Dim word As String = String.Empty

        Dim tens As Integer = 0

        For i As Integer = numberAsString.Length - 1 To 0 Step -1
            word = numberArray(ToInt32(numberAsString(i))) & " " & tensArray(tens) & word
            tens += 1
        Next

        parseNumberToWords = word.Trim()
    End Function
You'll have to define two arrays, one called numberArray ([0] = "Zero"; [1] = "One"; ...) and the other called tensArray ([0] = ""; [1] = "Ten"; [2] = "Hundred"; [3] = "Thousand"; ...). Though, as I see now, you'll have to parse the tens extra (twelve etc.).

Bobby
 
Back
Top