|
|
#1 |
|
Hyperactive Member
Join Date: Apr 02
Posts: 492
![]() |
I have an application that changes and $$ amount into a written out ammount. Ex. 250$ = Two Hundred Fifty Dollars. I have the following code that i want to modify, but i have found that it doesnt correctly translate the cents part, can you guys help me out on this one and tell me what is causing this, it doesnt always translate incorrectly only on certain occasions. I only have a text box and a command button so it should be easy to set up.
Example: 243.42 = Two hundres forty three dollars and forty one cents another example: 96.86 = Ninety Six Dollars and Eighty Five cents while when you do 6.32 it comes up correctly. What is causing this cause i cant find it. Thanks for you help in advance. VB Code:
Last edited by mrstuff68; Oct 10th, 2005 at 11:39 AM. |
|
|
|
|
|
#2 |
|
PowerPoster
Join Date: May 00
Location: New Jersey (USA)
Posts: 2,560
![]() ![]() ![]() |
Re: Need Troubleshooting Help
I have a sample app on my site that converts a number to words. It is implemented as a function "Num2Words". It only works on integers. To do what you want, you will need to call the function twice. Break up your string at the decimal point (you can use Split or other string-handling functions to do this), then call the routine once passing it the "dollars" portion and append the text " dollars and ", then call it again passing it the "cents" portion, and append that result along with the word "cents" to the final result.
The code can be found here: http://www.thevbprogrammer.com/index...ter=8&Topic=11 |
|
|
|
|
|
#3 |
|
Hyperactive Member
Join Date: Apr 02
Posts: 492
![]() |
Re: Need Troubleshooting Help
BruceG, I will look into your app, but i would still like to know what is causing the code that i currently have to act the way it is. If it was happening all the time then i would know that there is something wrong with the code but if it acts like that on certain instances, i would really like to know what is causing it.
|
|
|
|
|
|
#4 |
|
Banned
Join Date: Jun 04
Location: Center of it all
Posts: 17,901
![]() ![]() ![]() ![]() ![]() ![]() |
Re: Need Troubleshooting Help
You are using LONG's which don't handle division well. The drawback to using SINGLE is that there is a range limit of 32768. You could use Currency type though, which should be what you need. Change the type of C1 and C10 for sure, to solve your problem.
|
|
|
|
|
|
#5 |
|
Hyperactive Member
Join Date: Apr 02
Posts: 492
![]() |
Re: Need Troubleshooting Help
I knew it was something small.
Thanks dglienna |
|
|
|
|
|
#6 |
|
VB Addict
Join Date: Apr 04
Location: Inside the CPU...
Posts: 5,271
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Re: Need Troubleshooting Help [resolved]
Ever since I discovered CHOOSE function, it has made my functions very small in cases like this one.
VB Code:
__________________
Please appreciate posts that have helped you by clicking icon on the left of the post. My CodeBank Submissions: VBForums Reputation Saver • String Enum • Super Simple Tetris Game (VB.NET)Useful Stuff: 101 LINQ Samples • JSON Validator • XML Schema Validator • "How Do I" videos on MSDN • VB.NET and C# Comparison Latest articles on My Blog: Transparent background for Container and UserControls • Persist ListItems added to ListBox via JavaScript in ASP.NET • Grouping on one field and sorting on another in Crystal Reports • Quick Print Files to Default Printer • Add Keyboard and Mouse events to WebBrowser control • Search for a Node in TreeView by its Full Path • Drag & Drop Files into Your Form or Control • Truncate a Decimal Number to Some Fixed Decimal Places • Tetris Game in VB.NET • Advanced File/Folder Properties Viewer • Launching and Controlling External Applications from VB.NET Application • Good Coding Practices • VB.NET TextBox with Line Numbers NB: If you are getting the urge to PM me then ensure it is about the money you owe me and you want to return it (I accept HARD CASH and that too only US Dollars) BUT please do not use it to ask coding questions. If you want my help, then make a post and PM me it's link. If I can help, trust me I will... |
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|