Click here to Skip to main content
15,878,809 members
Articles / Programming Languages / Visual Basic
Article

Convert Number to Word

Rate me:
Please Sign up or sign in to vote.
2.98/5 (33 votes)
19 Feb 2008CPOL 202.2K   11K   34   39
Convert any decimal number to word using vb.net

Introduction

I have created this function for converting amount in Indian Rupees (INR). You can manipulate as you wish like decimal setting, Doller (any currency) Prefix.

Background

I have coded this function as per client's requirement to print word format of Billed Amount.

Using the code

This two dimensional array store the primary word convertion of number.

 Function retWord(ByVal Num As Decimal) As String
    'This two dimensional array store the primary word convertion of number.
    retWord = ""
    Dim ArrWordList(,) As Object = {{0, ""}, {1, "One"}, {2, "Two"}, {3, "Three"}, {4, "Four"}, _
                                    {5, "Five"}, {6, "Six"}, {7, "Seven"}, {8, "Eight"}, {9, "Nine"}, _
                                    {10, "Ten"}, {11, "Eleven"}, {12, "Twelve"}, {13, "Thirteen"}, {14, "Fourteen"}, _
                                    {15, "Fifteen"}, {16, "Sixteen"}, {17, "Seventeen"}, {18, "Eighteen"}, {19, "Nineteen"}, _
                                    {20, "Twenty"}, {30, "Thirty"}, {40, "Forty"}, {50, "Fifty"}, {60, "Sixty"}, _
                                    {70, "Seventy"}, {80, "Eighty"}, {90, "Ninety"}, {100, "Hundred"}, {1000, "Thousand"}, _
                                    {100000, "Lakh"}, {10000000, "Crore"}}

    Dim i As Integer
    For i = 0 To UBound(ArrWordList)
        If Num = ArrWordList(i, 0) Then
            retWord = ArrWordList(i, 1)
            Exit For
        End If
    Next
    Return retWord
End Function

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India
Pranav Patel
B.Sc, MCSD

I am serving my company as Sr. Software Engineer. I have more than 4 years of experience in Microsoft Technologies specially VB 6, VB.Net,C#,ASP.Net and MS SQL Server

Comments and Discussions

 
GeneralMy vote of 5 Pin
CodeDog13-Apr-11 4:58
CodeDog13-Apr-11 4:58 
GeneralMy vote of 1 Pin
yogeshd3918-Feb-11 1:23
yogeshd3918-Feb-11 1:23 
GeneralGood Article but with alot of limitations Pin
Albert Dadze17-Dec-10 6:00
Albert Dadze17-Dec-10 6:00 
GeneralMy vote of 3 Pin
Ashwani2k12-Jul-10 8:14
Ashwani2k12-Jul-10 8:14 
GeneralUsefull Work Pin
Vimal Upadhyay16-May-10 22:43
Vimal Upadhyay16-May-10 22:43 
GeneralThanks Pin
hrivero23-Mar-10 9:35
hrivero23-Mar-10 9:35 
GeneralMy vote of 1 Pin
geminiousgoel26-Jan-10 5:45
geminiousgoel26-Jan-10 5:45 
GeneralC# Code please Pin
yeswanths4-May-09 4:36
yeswanths4-May-09 4:36 
this is working wonderful in vb.net, can i have this in c# webform code please??
GeneralRe: C# Code please - Working upto 999999999.99 Pin
Member 468636426-Nov-09 0:09
Member 468636426-Nov-09 0:09 
GeneralThanks a lot Pin
rajakar0123-Dec-08 19:00
rajakar0123-Dec-08 19:00 
GeneralTry One million and above Pin
sensei41200131-Aug-08 22:20
sensei41200131-Aug-08 22:20 
GeneralThanx a lot Pin
Amit Code Project19-Aug-08 2:24
Amit Code Project19-Aug-08 2:24 
GeneralThanks Pin
csiconnect12-Aug-08 3:06
csiconnect12-Aug-08 3:06 
GeneralThanks Pin
Rai Shahid15-Jul-08 23:38
Rai Shahid15-Jul-08 23:38 
GeneralIndRs. converter PinPopular
Arijit Manna15-Jul-08 2:31
Arijit Manna15-Jul-08 2:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.