convert indian rupees from numbers to words

i want the money in numbers to be converted to words i.e in crores,lakhs,thousands,hundred.........
[99 byte] By [hereiskishore] at [2007-11-20 9:17:40]
# 1 Re: convert indian rupees from numbers to words
i want the money in numbers to be converted to words i.e in crores,lakhs,thousands,hundred.........
There is no built-in functionality for this in .NET. You will have to write your own logic based on If conditions and some maths.
Shuja Ali at 2007-11-10 3:09:05 >
# 2 Re: convert indian rupees from numbers to words
Hi. I am new here so please bear with me. I think you should write yur own code that should detect first the length of the number (converted to a string) and than the position of the decimal place. That would give you a good indication about the words you have to use, that take digit by digit and appending the words to it (e.g 1 found in the thousands category will translate in "one thousands" but any number > 1 will be "n" + "thousands.

It's tedious but this is it. I wrote some similar program that converted roman numbers to intergers and viceversa at some point. software for a publishing housa where the roman numbers were chapters or article numbers or something like that.

--adr
apopescu at 2007-11-10 3:10:05 >
# 3 Re: convert indian rupees from numbers to words
Here's the logic needed, from a VB6 app.

Option Explicit

Private Sub Command1_Click()
Dim num As Long
Dim str As String
num = Val(Text1.Text)
str = convert(num)
MsgBox str
End Sub

Private Sub Form_Load()
Text1.Text = 1240
End Sub

Function convert(n As Long) As String
Dim s As String
Dim x As Integer
If n > 1000 Then
x = (n \ 1000)
s = sngl(x) & " Thousand"
n = n - (x * 1000)
End If
If n > 100 Then
x = (n \ 100)
s = s & sngl(x) & " Hundred "
n = n - (x * 100)
End If
If n > 10 Then
x = (n \ 10)
Select Case x
Case 2
s = s & "Twenty"
Case 3
s = s & "Thirty"
Case 4
s = s & "Fourty"
Case 5
s = s & "Fifty"
Case 6
s = s & "Sixty"
Case 7
s = s & "Seventy"
Case 8
s = s & "Eighty"
Case 9
s = s & "Ninety"
End Select
n = n - (x * 10)
End If
s = s & sngl(CInt(n))
If n = 0 Then s = "Zero"
convert = s
End Function

Function sngl(x As Integer) As String
Dim s As String
Select Case x
Case 1
s = s & " One"
Case 2
s = s & " Two"
Case 3
s = s & " Three"
Case 4
s = s & " Four"
Case 5
s = s & " Five"
Case 6
s = s & " Six"
Case 7
s = s & " Seven"
Case 8
s = s & " Eight"
Case 9
s = s & " Nine"
End Select
sngl = s
End Function
dglienna at 2007-11-10 3:11:04 >