|
|
#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 12:39 PM. |
|
|
|
|
|
#2 |
|
PowerPoster
Join Date: May 00
Location: New Jersey (USA)
Posts: 2,543
![]() ![]() ![]() |
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 |
|
Power Poster
Join Date: Apr 04
Location: Inside the CPU...
Posts: 4,301
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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:
__________________
Pradeep If anyones answer has helped you please show your appreciation by rating that answer. Just click icon on the left of the post you wish to rate.My Blog | 101 LINQ Samples | JSON Validator | XML Schema Validator | String Enum | "How Do I" videos on MSDN | VB.NET and C# Comparison Some Signatures that contain Useful Stuff: jmcilhinney | szlamany | MartinLiss | RobDog888 | dee-u | RhinoBull | si_the_geek | koolsid | Negative0 | VBDT | gep13 | NickThissen... |
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|