Click here to Skip to main content
15,881,852 members
Articles / Programming Languages / Visual Basic
Tip/Trick

Convert Number To String (English and Arabic)

Rate me:
Please Sign up or sign in to vote.
2.00/5 (3 votes)
29 Jun 2010Ms-PL 22.2K   296   1   2
It converts 123 to One Hundred twenty three

Introduction

This is a class that has 3 major functions:

  1. NumToString which converts any number to string (Word) 
    For 123 -->> One Hundred Twenty Three
  2. getUnits which takes any decimal number and returns the unit number 
    For a number like 2.6 it returns 2, but without using the split function
  3. GetChange which takes any decimal number and returns the change number 
    For a number like 2.6 it returns 6000, but without using the split function

Background

In most financial applications, we know how to convert the value of money to words (String).

The NumToString does what you want. All you need to do is call the class and use it to convert the num.

VB.NET
'Call the DLL
Dim munClass As New noToStringDll.NumberWriter_en

' to use munToString 
Dim num As Double = 125.125
Dim numStr As String = munClass.NumToString(num)
MsgBox(numStr)

' to use getUnits
Dim numUnit As Long = munClass.getUnits(num)
MsgBox(numUnit)

' to use getChange
Dim numChange As Long = munClass.GetChange(num)
MsgBox(numChange)

Points of Interest

I was very happy when I finished getChange and getUnits because all the developers I asked about how to get it from any double number used split (including myself), but with this one, it's all math.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Kuwait Kuwait
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 1 Pin
Jαved30-Mar-12 2:27
professionalJαved30-Mar-12 2:27 
GeneralMy vote of 1 Pin
R. Giskard Reventlov30-Jun-10 0:24
R. Giskard Reventlov30-Jun-10 0:24 
A couple of sentences and a code dump do not an article make! Convert to a tip/trick or blog post and format properly.

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.