Hi... does someone know how to CONVERT NUMBERS INTO WORDS IN VISUAL BASIC 2008 until millions by using recursion???


if yes... can you please share to me the code???

thanks a lot!!!

how could i make a program that will convert the numeric number into words?
i want the whole sample code..please..
thank you

waynespangler has provided you with two links that show how the conversion works. What more do you need?

commented: Agree +5

@ NetJunkie what i want is the whole code for this program and what properties i used to be and how to show the output,thank you.

commented: efforts? -1

We don't give ready made programs here, we help people develop their own.
Despite this the links provided by waynespangler contain the sample code.

Try this code for converting number into words

Public Function NumberToString(ByVal num_str As String) As String ', Optional ByVal use_us_group_names As Boolean = True
        ' Get the appropiate group names.
        Dim groups() As String
        'If use_us_group_names Then
        '    groups = New String() {"", "thousand", "million", "billion", "trillion", "quadrillion", "quintillion", "sextillion", "septillion", "octillion", "nonillion", "decillion", "undecillion", "duodecillion", "tredecillion", "quattuordecillion", "quindecillion", "sexdecillion", "septendecillion", "octodecillion", "novemdecillion", "vigintillion"}
        'Else
        groups = New String() {"", "thousand", "million", "milliard", "billion", "1000 billion", "trillion", "1000 trillion", "quadrillion", "1000 quadrillion", "quintillion", "1000 quintillion", "sextillion", "1000 sextillion", "septillion", "1000 septillion", "octillion", "1000 octillion", "nonillion", "1000 nonillion", "decillion", "1000 decillion"}
        'End If

        ' Clean the string a bit.
        ' Remove "$", ",", leading zeros, and
        ' anything after a decimal point.
        Const CURRENCY As String = "$"
        Const SEPARATOR As String = ","
        Const DECIMAL_POINT As String = "."
        num_str = num_str.Replace(CURRENCY, "").Replace(SEPARATOR, "")
        num_str = num_str.TrimStart(New Char() {"0"c})
        Dim pos As Integer = num_str.IndexOf(DECIMAL_POINT)
        If pos = 0 Then
            Return "zero"
        ElseIf pos > 0 Then
            num_str = num_str.Substring(0, pos - 1)
        End If

        ' See how many groups there will be.
        Dim num_groups As Integer = (num_str.Length + 2) \ 3

        ' Pad so length is a multiple of 3.
        num_str = num_str.PadLeft(num_groups * 3, " "c)

        ' Process the groups, largest first.
        Dim result As String = ""
        Dim group_num As Integer
        For group_num = num_groups - 1 To 0 Step -1
            ' Get the next three digits.
            Dim group_str As String = num_str.Substring(0, 3)
            num_str = num_str.Substring(3)
            Dim group_value As Integer = CInt(group_str)

            ' Convert the group into words.
            If group_value > 0 Then
                If group_num >= groups.Length Then
                    result &= GroupToWords(group_value) & _
                        " ?, "
                Else
                    result &= GroupToWords(group_value) & _
                        " " & groups(group_num) & ", "
                End If
            End If
        Next group_num

        ' Remove the trailing ", ".
        If result.EndsWith(", ") Then
            result = result.Substring(0, result.Length - 2)
        End If

        Return result.Trim()
    End Function
    ' Convert a number between 0 and 999 into words.
    Private Function GroupToWords(ByVal num As Integer) As String
        Static one_to_nineteen() As String = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eightteen", "nineteen"}
        Static multiples_of_ten() As String = {"twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"}

        ' If the number is 0, return an empty string.
        If num = 0 Then Return ""

        ' Handle the hundreds digit.
        Dim digit As Integer
        Dim result As String = ""
        If num > 99 Then
            digit = num \ 100
            num = num Mod 100
            result = one_to_nineteen(digit) & " hundred"
        End If

        ' If num = 0, we have hundreds only.
        If num = 0 Then Return result.Trim()

        ' See if the rest is less than 20.
        If num < 20 Then
            ' Look up the correct name.
            result &= " " & one_to_nineteen(num)
        Else
            ' Handle the tens digit.
            digit = num \ 10
            num = num Mod 10
            result &= " " & multiples_of_ten(digit - 2)

            ' Handle the final digit.
            If num > 0 Then
                result &= " " & one_to_nineteen(num)
            End If
        End If

        Return result.Trim()
    End Function

thank you very much....it helps me a lot...thank you

Here is my example code (which i did some time ago) and actually used is some where:

Public Shared Function NumberToWords(number As Integer) As String
	If number = 0 Then
		Return "zero"
	End If

	If number < 0 Then
		Return "minus " & NumberToWords(Math.Abs(number))
	End If

	Dim words As String = ""

	If (number \ 1000000) > 0 Then
		words += NumberToWords(number \ 1000000) & " million "
		number = number Mod 1000000
	End If

	If (number \ 1000) > 0 Then
		words += NumberToWords(number \ 1000) & " thousand "
		number = number Mod 1000
	End If

	If (number \ 100) > 0 Then
		words += NumberToWords(number \ 100) & " hundred "
		number = number Mod 100
	End If

	If number > 0 Then
		If words <> "" Then
			words += "and "
		End If

		Dim unitsMap = New () {"zero", "one", "two", "three", "four", "five", _
			"six", "seven", "eight", "nine", "ten", "eleven", _
			"twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", _
			"eighteen", "nineteen"}
		Dim tensMap = New () {"zero", "ten", "twenty", "thirty", "forty", "fifty", _
			"sixty", "seventy", "eighty", "ninety"}

		If number < 20 Then
			words += unitsMap(number)
		Else
			words += tensMap(number \ 10)
			If (number Mod 10) > 0 Then
				words += "-" & unitsMap(number Mod 10)
			End If
		End If
	End If

	Return words
End Function

Put this code on any event u want
I had Written it on Button Click

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    TextBox1.Text = InWords(CObj(TextBox1.Text))
End Sub
Function InWords(ByVal amt As Object) As Object
    Dim FIGURE As Object
    Dim LENFIG As Integer
    Dim FIGLEN As Integer
    Dim i As Integer
    Dim WORDs(19) As String
    Dim tens(9) As String
    WORDs(1) = "One"
    WORDs(2) = "Two"
    WORDs(3) = "Three"
    WORDs(4) = "Four"
    WORDs(5) = "Five"
    WORDs(6) = "Six"
    WORDs(7) = "Seven"
    WORDs(8) = "Eight"
    WORDs(9) = "Nine"
    WORDs(10) = "Ten"
    WORDs(11) = "Eleven"
    WORDs(12) = "Twelve"
    WORDs(13) = "Thirteen"
    WORDs(14) = "Fourteen"
    WORDs(15) = "Fifteen"
    WORDs(16) = "Sixteen"
    WORDs(17) = "Seventeen"
    WORDs(18) = "Eighteen"
    WORDs(19) = "Nineteen"


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


    FIGURE = amt

    FIGURE = Format(FIGURE, "FIXED")
    FIGLEN = Len(FIGURE)


    If FIGLEN < 12 Then
        FIGURE = Space(12 - FIGLEN) & FIGURE
    End If


    For i = 1 To 3
        If Val(Microsoft.VisualBasic.Left(FIGURE, 2)) < 20 And Val(Microsoft.VisualBasic.Left(FIGURE, 2)) > 0 Then
            InWords = InWords & WORDs(Val(Microsoft.VisualBasic.Left(FIGURE, 2)))
        ElseIf Val(Microsoft.VisualBasic.Left(FIGURE, 2)) > 19 Then
            InWords = InWords & tens(Val(Microsoft.VisualBasic.Left(FIGURE, 1)))
            InWords = InWords & WORDs(Val(Microsoft.VisualBasic.Right(Microsoft.VisualBasic.Left(FIGURE, 2), 1)))
        End If


        If i = 1 And Val(Microsoft.VisualBasic.Left(FIGURE, 2)) > 0 Then
            InWords = InWords & " Crore "
        ElseIf i = 2 And Val(Microsoft.VisualBasic.Left(FIGURE, 2)) > 0 Then
            InWords = InWords & " Lakh "
        ElseIf i = 3 And Val(Microsoft.VisualBasic.Left(FIGURE, 2)) > 0 Then
            InWords = InWords & " Thousand "
        End If
        FIGURE = Mid(FIGURE, 3)
    Next i


    If Val(Microsoft.VisualBasic.Left(FIGURE, 1)) > 0 Then
        InWords = InWords & WORDs(Val(Microsoft.VisualBasic.Left(FIGURE, 1))) + " Hundred "
    End If


    FIGURE = Mid(FIGURE, 2)


    If Val(Microsoft.VisualBasic.Left(FIGURE, 2)) < 20 And Val(Microsoft.VisualBasic.Left(FIGURE, 2)) > 0 Then
        InWords = InWords & WORDs(Val(Microsoft.VisualBasic.Left(FIGURE, 2)))
    ElseIf Val(Microsoft.VisualBasic.Left(FIGURE, 2)) > 19 Then
        InWords = InWords & tens(Val(Microsoft.VisualBasic.Left(FIGURE, 1)))
        InWords = InWords & WORDs(Val(Microsoft.VisualBasic.Right(Microsoft.VisualBasic.Left(FIGURE, 2), 1)))
    End If
    FIGURE = Mid(FIGURE, 4)




    If Val(Microsoft.VisualBasic.Left(FIGURE, 9)) > 1 Then
        InWords = InWords & " Rupees "
    ElseIf Val(Microsoft.VisualBasic.Left(FIGURE, 9)) = 1 Then
        InWords = InWords & " Rupee "
    End If


    If Val(FIGURE) > 0 Then
        InWords = InWords & " And "
        If Val(Microsoft.VisualBasic.Left(FIGURE, 2)) < 20 And Val(Microsoft.VisualBasic.Left(FIGURE, 2)) > 0 Then
            InWords = InWords & WORDs(Val(Microsoft.VisualBasic.Left(FIGURE, 2)))
        ElseIf Val(Microsoft.VisualBasic.Left(FIGURE, 2)) > 19 Then
            InWords = InWords & tens(Val(Microsoft.VisualBasic.Left(FIGURE, 1)))
            InWords = InWords & WORDs(Val(Microsoft.VisualBasic.Right(Microsoft.VisualBasic.Left(FIGURE, 2), 1)))
        End If
        InWords = InWords & " Paise "
    End If
    FIGURE = amt
    FIGURE = Format(FIGURE, "FIXED")
    If Val(FIGURE) > 0 Then
        'InWords = InWords & " Only "
        Return InWords & " Only"
    Else
        Return "Null"

    End If

End Function

End Class

I hope the person who posted the question 7 years ago has waited all the time to get your answer. Just keep on doing the good work.

And I bet he'll be really happy to get an answer that fails to meet the stated requirement for a recursive solution.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.