Click here to Skip to main content
15,881,172 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

 
QuestionPerfect solution Pin
ravikumar336-Jul-17 21:30
ravikumar336-Jul-17 21:30 
QuestionNeed modification Pin
Member 406098020-Mar-17 5:29
Member 406098020-Mar-17 5:29 
QuestionThank you... Pin
veera kumar19-Aug-16 23:44
veera kumar19-Aug-16 23:44 
Questionerro in conversion Pin
Member 1249044827-Apr-16 23:43
Member 1249044827-Apr-16 23:43 
GeneralWorked Pin
Member 1112113630-Sep-14 7:16
Member 1112113630-Sep-14 7:16 
GeneralTHANKS A LOT Pin
Member 1111700928-Sep-14 22:32
Member 1111700928-Sep-14 22:32 
Questionnumber conversion Pin
Member 1102112918-Aug-14 21:05
Member 1102112918-Aug-14 21:05 
Questionnumber conversion using vb.net Pin
Member 1102112918-Aug-14 20:53
Member 1102112918-Aug-14 20:53 
QuestionTHANKS A LOT DEAR..... Pin
satishgurav18-Jul-14 18:21
satishgurav18-Jul-14 18:21 
GeneralMy vote of 3 Pin
Ashok Pathirana21-May-14 18:38
professionalAshok Pathirana21-May-14 18:38 
Questionthanks Pin
Ram A Singh14-Aug-13 6:50
Ram A Singh14-Aug-13 6:50 
QuestionIt never converts zeros Pin
JAYANTHIMURUGESAN26-Mar-13 14:33
JAYANTHIMURUGESAN26-Mar-13 14:33 
GeneralThanks Pin
taenel l pasaylo27-Jan-13 1:27
taenel l pasaylo27-Jan-13 1:27 
Tnx for dis code sir, It really help me=)..
QuestionNot perfect Pin
alifaris5-Nov-12 8:36
alifaris5-Nov-12 8:36 
Questionproject Pin
rahul binaikia29-May-12 4:58
rahul binaikia29-May-12 4:58 
QuestionThanks !!! Pin
Member 340016411-May-12 15:17
Member 340016411-May-12 15:17 
GeneralMy vote of 5 Pin
Jack_32122-Apr-12 23:38
Jack_32122-Apr-12 23:38 
QuestionThanks Pin
Member 850926513-Mar-12 19:09
Member 850926513-Mar-12 19:09 
GeneralMy vote of 4 Pin
Md. Marufuzzaman2-Jan-12 19:22
professionalMd. Marufuzzaman2-Jan-12 19:22 
GeneralMy vote of 5 Pin
Аslam Iqbal26-Dec-11 20:43
professionalАslam Iqbal26-Dec-11 20:43 
GeneralNice Work Pin
maruf2111-Dec-11 12:17
maruf2111-Dec-11 12:17 
GeneralMy vote of 1 Pin
Member 846869111-Dec-11 4:16
Member 846869111-Dec-11 4:16 
GeneralMy vote of 1 Pin
divyanivas18-Aug-11 9:10
divyanivas18-Aug-11 9:10 
GeneralHow do increase to more than 999999999.99 Pin
D Kr29-Apr-11 19:50
D Kr29-Apr-11 19:50 
GeneralMy vote of 5 Pin
CodeDog13-Apr-11 4:58
CodeDog13-Apr-11 4:58 

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.