469,341 Members | 6,935 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,341 developers. It's quick & easy.

crystal report currency conversion

Hi, i am developing software in asp.net using vb coding and MS ACCESS database.

I created a crystal report for printing sales bill.

Now i need to convert currency into words and need to print. ex: 3,250 as "Three Thousand Two Hundred and Fifty only".

How can i write codings and make to print using crystal report.

Thanks in advance.
May 10 '07 #1
13 12036
dip_developer
648 Expert 512MB
Hi, i am developing software in asp.net using vb coding and MS ACCESS database.

I created a crystal report for printing sales bill.

Now i need to convert currency into words and need to print. ex: 3,250 as "Three Thousand Two Hundred and Fifty only".

How can i write codings and make to print using crystal report.

Thanks in advance.
crystal report has nothing to do your conversion.....you have to convert Currency in Words through code in your application....Then pass the string(e.g--"Three Thousand Two Hundred and Fifty only".) to crystal report as a parameter....

to convert your currency to word search google...many vb.net classes are available on NET for this conversion.....
May 10 '07 #2
Hi Perumal,
I used a formula field for this conversion. type the following code in it and try.

All the best.
Expand|Select|Wrap|Line Numbers
  1. if Split (cstr(Sum ({ExportView.Amount})),".")[2]="00" then 
  2.  
  3.    {ExportView.CurrencyName} + " " + ToWords (Sum ({ExportView.Amount}),0) + " Only "
  4.  
  5. else 
  6.     {ExportView.CurrencyName} + " " + ToWords (Sum ({ExportView.Amount}),0) + " and " 
  7.    + ToWords ((Round(Sum ({ExportView.Amount}),2)
  8.    - Int(Sum ({ExportView.Amount}))) * 100, 0) + " " + {ExportView.DecimalPart} + " only "
sudha
May 10 '07 #3
Hi Perumal,
i used a decimal number rounded to two decimal places and so used the above code which is perplexing. if you dont want to check the paise part ur code is like this.

Expand|Select|Wrap|Line Numbers
  1. "Rupees " + ToWords (Sum ({ExportView.Amount}),0) + " Only "
or else you find in the below url
"http://www.eggheadcafe.com/community/aspnet/14/10016490/convert-number-to-words.aspx"
with regards,
sudha
May 10 '07 #4
Hi Sudha,
Thanks for your reply.

I implemented your coding in my crystal report. but i am getting error in part + " " + before ToWords
And also i am not aware of Exportiew.Amount and ExportView.Currency.

could you please tell me the details of those fields.
May 11 '07 #5
Thanks.

Its working fine.

TRY THIS CODE
Expand|Select|Wrap|Line Numbers
  1. if split(cstr({tablename.fieldname)),".")[2]="00" then
  2.      replace(ToWords({tablename.fieldname},0)+ " only","-"," ")
  3. else
  4.      replace(ToWords(cdbl((tablename.fieldname})-cdbl(split(cstr({tablename.fieldname}),"."[2]/100),0) + " and " + ToWords(cdblsplit(cstr({tablename.fieldname}),"."[2]),0) + " paise only","-"," ")
May 12 '07 #6
Hi


I tried ur code and got error message as "The ) is missing". So, can u please tell me wat could be wrong.

Regards,
Pavithra.C
May 26 '07 #7
Hi pavithra,
Now try the following code
Expand|Select|Wrap|Line Numbers
  1. if split(cstr({tablename.fieldname}),".")[2]="00" then
  2. replace(ToWords({tablename.fieldname},0)+ " only","-"," ")
  3. else
  4. replace(ToWords(cdbl({tablename.fieldname})-cdbl(split(cstr({tablename.fieldname}),"."[2]/100),0)) + " and " + ToWords(cdblsplit(cstr({tablename.fieldname}),"."[2]),0) + " paise only","-"," ")
May 26 '07 #8
Expand|Select|Wrap|Line Numbers
  1. if split(cstr({tablename.fieldname}),".")[2]="00" then
  2. replace(ToWords({tablename.fieldname},0)+ " only","-"," ")
  3. else
  4. replace(ToWords(cdbl({tablename.fieldname})-cdbl(split(cstr({tablename.fieldname}),"."[2]/100),0)) + " and " + ToWords(cdblsplit(cstr({tablename.fieldname}),"."[2]),0) + " paise only","-"," ")

I have try your code but still there is error showing ) is missing out please sort out it's urgent
Sep 28 '07 #9
Hi

You try this code now

Expand|Select|Wrap|Line Numbers
  1. if split(cstr({tablename.fieldname}),".")[2]="00" then replace(ToWords({tablename.fieldname},0)+" only","-"," ")
  2. else
  3. replace(Towords((cdbl({tablename.fieldname})-cdbl(split(cstr({tablename.fieldname}),".")[2])/100),0)+" and " +ToWords(cdbl(split(cstr({tablename.fieldname}),".")[2]),0)+" paise only","-"," ")


Hope it will work.

If not you just mail me to perumalvps@gmail.com
Oct 4 '07 #10
sans
2
hai

I am santhanam

I need number to word convertion in crystal report for 100041.22

(one Lakh forty one and twentytwo only)
Jan 10 '08 #11
sans
2
hai

I am santhanam

I need a code for number to word convertion for 100041.22
Jan 10 '08 #12
It is worthless to post now but still for the sake of others who come to this link on searching.

You can do the same in the code behind as follows for ASP.NET

ASPX page:

Expand|Select|Wrap|Line Numbers
  1.   <form id="form1" runat="server">
  2.   <div>
  3.     <asp:TextBox ID="TextBox1" runat="server">
  4.     </asp:TextBox><asp:Button ID="Button1" runat="server" Text="Button" />
  5.   </div>
  6.   </form>
Code behind:

Expand|Select|Wrap|Line Numbers
  1. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.     Response.Write(NumberToWords(CDbl(TextBox1.Text)))
  3.   End Sub
  4.   Public Function NumberToWords(ByVal OrigNum As Long) As String
  5.     'This function converts numbers to words. For example 101 -> One hundred and one
  6.     'It uses standard english notation and will only accept positive long numbers
  7.     Dim billionpart As Long
  8.     Dim millionpart As Long
  9.     billionpart = Int(OrigNum / 10000000)
  10.     millionpart = OrigNum Mod 10000000
  11.     NumberToWords = HundredsToWords(billionpart) & IIf(billionpart <> 0, " Crore", "")
  12.     If millionpart > 99 Then
  13.       NumberToWords = NumberToWords & IIf(millionpart <> 0 And billionpart <> 0, " ", "") & millionstowords(millionpart)
  14.     Else
  15.       NumberToWords = NumberToWords & IIf(millionpart <> 0 And billionpart <> 0, " and ", "") & millionstowords(millionpart)
  16.     End If
  17.   End Function
  18.  
  19.   Public Function millionstowords(ByVal millionnumber As Long)
  20.     Dim millionpart As Long
  21.     Dim thousandpart As Long
  22.     millionpart = Int(millionnumber / 100000)
  23.     thousandpart = millionnumber Mod 100000
  24.     millionstowords = HundredsToWords(millionpart) & IIf(millionpart <> 0, " Lac", "")
  25.     If thousandpart > 99 Then
  26.       millionstowords = millionstowords & IIf(thousandpart <> 0 And millionpart <> 0, " ", "") & thousandstowords(thousandpart)
  27.     Else
  28.       millionstowords = millionstowords & IIf(thousandpart <> 0 And millionpart <> 0, " and ", "") & thousandstowords(thousandpart)
  29.     End If
  30.   End Function
  31.  
  32.  
  33.   Public Function thousandstowords(ByVal thousandnumber As Long) As String
  34.     Dim thousandpart As Long
  35.     Dim HundredPart As Long
  36.     HundredPart = thousandnumber Mod 1000
  37.     thousandpart = Int(thousandnumber / 1000)
  38.     thousandstowords = HundredsToWords(thousandpart) & IIf(thousandpart <> 0, " thousand", "")
  39.     If HundredPart > 99 Then
  40.       thousandstowords = thousandstowords & IIf(HundredPart <> 0 And thousandpart <> 0, " ", "") & HundredsToWords(HundredPart)
  41.     Else
  42.       thousandstowords = thousandstowords & IIf(HundredPart <> 0 And thousandpart <> 0, " and ", "") & HundredsToWords(HundredPart)
  43.     End If
  44.   End Function
  45.  
  46.  
  47.   Public Function HundredsToWords(ByVal HundredNumber As Long) As String
  48.     'This function converts a three digit long to the hundred wording
  49.     Dim TensPart As Long
  50.     Dim HundredPart As Long
  51.     TensPart = HundredNumber Mod 100
  52.     HundredPart = Int(HundredNumber / 100)
  53.     Select Case HundredPart
  54.       Case 0
  55.         HundredsToWords = TensToWords(TensPart)
  56.       Case Else
  57.         HundredsToWords = SingleToWord(HundredPart) & " Hundred" & IIf(TensPart <> 0, " and ", "") & TensToWords(TensPart)
  58.     End Select
  59.   End Function
  60.  
  61.  
  62.   Public Function TensToWords(ByVal TensNumber As Long) As String
  63.     'This function converts a two digit long to a two digit wording
  64.     Dim tens As Long
  65.     Dim Singles As Long
  66.     tens = Int(TensNumber / 10)
  67.     Singles = TensNumber Mod 10
  68.     Select Case tens
  69.       Case 0
  70.         TensToWords = SingleToWord(Singles)
  71.       Case 1
  72.         TensToWords = teens(TensNumber)
  73.       Case 2
  74.         TensToWords = "Twenty" & IIf(Singles <> 0, " ", "") & SingleToWord(Singles)
  75.       Case 3
  76.         TensToWords = "Thirty" & IIf(Singles <> 0, " ", "") & SingleToWord(Singles)
  77.       Case 4
  78.         TensToWords = "Fourty" & IIf(Singles <> 0, " ", "") & SingleToWord(Singles)
  79.       Case 5
  80.         TensToWords = "Fifty" & IIf(Singles <> 0, " ", "") & SingleToWord(Singles)
  81.       Case 6
  82.         TensToWords = "Sixty" & IIf(Singles <> 0, " ", "") & SingleToWord(Singles)
  83.       Case 7
  84.         TensToWords = "Seventy" & IIf(Singles <> 0, " ", "") & SingleToWord(Singles)
  85.       Case 8
  86.         TensToWords = "Eighty" & IIf(Singles <> 0, " ", "") & SingleToWord(Singles)
  87.       Case 9
  88.         TensToWords = "Ninety" & IIf(Singles <> 0, " ", "") & SingleToWord(Singles)
  89.     End Select
  90.   End Function
  91.  
  92.  
  93.   Public Function SingleToWord(ByVal SingleDigit As Long) As String
  94.     Select Case SingleDigit
  95.       Case 1
  96.         SingleToWord = "One"
  97.       Case 2
  98.         SingleToWord = "Two"
  99.       Case 3
  100.         SingleToWord = "Three"
  101.       Case 4
  102.         SingleToWord = "Four"
  103.       Case 5
  104.         SingleToWord = "Five"
  105.       Case 6
  106.         SingleToWord = "Six"
  107.       Case 7
  108.         SingleToWord = "Seven"
  109.       Case 8
  110.         SingleToWord = "Eight"
  111.       Case 9
  112.         SingleToWord = "Nine"
  113.       Case 0
  114.         SingleToWord = ""
  115.     End Select
  116.   End Function
  117.  
  118.  
  119.   Public Function teens(ByVal TeenNumber As Long) As String
  120.     Select Case TeenNumber
  121.       Case 10
  122.         teens = "Ten"
  123.       Case 11
  124.         teens = "Eleven"
  125.       Case 12
  126.         teens = "Twelve"
  127.       Case 13
  128.         teens = "Thirteen"
  129.       Case 14
  130.         teens = "Fourteen"
  131.       Case 15
  132.         teens = "Fifteen"
  133.       Case 16
  134.         teens = "Sixteen"
  135.       Case 17
  136.         teens = "Seventeen"
  137.       Case 18
  138.         teens = "Eighteen"
  139.       Case 19
  140.         teens = "Nineteen"
  141.     End Select
  142.   End Function
  143.  
As far as I tested it wont work over 999999999 (1 Hundred Crores) but you can modify it accordingly and set limitations

Modified from <link snipped>
See Ya!
Sep 21 '10 #13
Thx a lot CandorZ for writing whole code.it help a lot to me.
Here I have done this Code in C#.NET,hope it will help to others who wants code in C#.


Expand|Select|Wrap|Line Numbers
  1. Protected Sub Button1_Click(object sender, EventArgs e) 
  2. {
  3.     Response.Write(NumberToWords(CDbl(TextBox1.Text)));
  4. }
  5.  
  6.   Public string NumberToWords(Long OrigNum)
  7.   {
  8.   'This function converts numbers to words. For example 101 -> One hundred and one
  9.     'It uses standard english notation and will only accept positive long numbers
  10.     Long bilionpart;
  11.     Long millionpart;
  12.  
  13.     billionpart = Convert.ToInt32(OrigNum / 10000000);
  14.     millionpart = OrigNum Mod 10000000;
  15.     NumberToWords = HundredsToWords(billionpart) & IIf(billionpart <> 0, " Crore", "")
  16.     If( millionpart > 99)
  17.       NumberToWords = NumberToWords & IIf(millionpart <> 0 And billionpart <> 0, " ", "") & millionstowords(millionpart);
  18.     Else
  19.       NumberToWords = NumberToWords & IIf(millionpart <> 0 And billionpart <> 0, " and ", "") & millionstowords(millionpart);
  20.     return NumberToWords;
  21.   }
  22.  
  23.   Public void millionstowords(Long millionnumber)
  24.     {
  25.         Long millionpart;
  26.         Long thousandpart;
  27.         millionpart = Convert.ToInt32(millionnumber / 100000);
  28.         thousandpart = millionnumber Mod 100000;
  29.         millionstowords = HundredsToWords(millionpart) & IIf(millionpart <> 0, " Lac", "");
  30.         If (thousandpart > 99)
  31.             millionstowords = millionstowords & IIf(thousandpart <> 0 And millionpart <> 0, " ", "") & thousandstowords(thousandpart);
  32.         Else
  33.         millionstowords = millionstowords & IIf(thousandpart <> 0 And millionpart <> 0, " and ", "") & thousandstowords(thousandpart);
  34.     }
  35.  
Feb 7 '14 #14

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Ave | last post: by
3 posts views Thread by oscar | last post: by
3 posts views Thread by John H. | last post: by
reply views Thread by Zoury | last post: by
2 posts views Thread by blackdevil1979 | last post: by
3 posts views Thread by Agnes | last post: by
5 posts views Thread by jmar | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.