473,800 Members | 2,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

crystal report currency conversion

64 New Member
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
13 12531
sans
2 New Member
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 New Member
hai

I am santhanam

I need a code for number to word convertion for 100041.22
Jan 10 '08 #12
CandorZ
1 New Member
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
sagarrupani
5 New Member
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

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

Similar topics

3
7239
by: Ave | last post by:
Hi I am hoping someone can help me or even point me in the right direction, this problem has been doing my head in, I have a report which has 3 groups say currency, payment method and bankable, i have totals in the footers of these groups, when any of the fields specifed on the groups change the footer is displayed which is how crystal does it, but what i want is if any of the fields used for the groups change i only want one group...
3
520
by: oscar | last post by:
is there a way of integrating mysql databases into the .net crystal reports? in the report wizard i have options for sql databases, but nothing for mysql. is there a plugin i'm missing for it? i've tried creating a dataset and filling it with the data from a mysql query, but it still does not show up in the wizard. i have also tried to create fields and import data to them, but there seems to be no way of accessing the crystal report...
3
2438
by: John H. | last post by:
Hi, Why if set a DataTable in Crystal Report Net Table with method SetDataSource, 'ReportDocument.SetDataSource(oDataTable)', lost the Number and Currency format with the decimal digits and Currency symbol?
0
1597
by: Zoury | last post by:
Hi there ! :O) I'm having a two strange behaviors with Crystal Report which seems to have the same cause.. All the fields used in the reports comes from some SQL Server views. *** 1st Problem :
2
12469
by: blackdevil1979 | last post by:
Hello, Is there a way to format the data when it is passed into the Crystal Report(CR).. for example.. In the original table, a number may be left aligned, how to change it to right alignment?.. in other words I want to change it's Format: Horizontal Alignment from Left To Right if the data passed in is an Integer, Currency, or DateTime.
3
2098
by: Agnes | last post by:
I got this error when I preview report in Vb.net "Unknown query Engine Error" Is that my crystal report got something wrong ??? or my SQL server is too slow to response ?? Thanks a lot From agnes
5
3741
by: jmar | last post by:
I posted a week ago and received one response. I'm looking for the opinion of several experienced .NET people before I proceed so I'm posting again. Sorry for the repost... I am updating a VB4.0 quote generation program to VB.net. The old program takes user inputs, performs calculations, saves the data to Access databases and uses Crystal Reports 5.0 to generate a quote. A while back users obviously wanted to be able to edit/e-mail ...
3
9925
by: LataChavan | last post by:
I have tried to look for a solution to the problem of sending parameters to stored procedures through crystal report. Following is the code: Now what happens is that if i do not apply the logon information the crystal reports works fine by accepting the parameter values and giving the Database Logon prompt when we run the report. But I would like to give the logon information at runtime. If I give the info at runtime the "stored procedure"...
0
1880
by: amiga500 | last post by:
Hello, I am developing a crystal report called Expense Report (I am not an expert Crystal Report designer) if someone could help me in this problem I would be greatly appreciate it. The report would be as follows: Description Sun Mon
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10504
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10274
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10251
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7576
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.