Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / need to convert Strings to currency

Author
Message
Flubber
20
Years of Service
User Offline
Joined: 30th May 2004
Location: USA
Posted: 1st Sep 2005 02:28
DB doesn't have a currency variable and I can't use floats because I get rounding errors. Can any one show me how to convert integers to strings strings to integers. I know how to use the Str$ comand and integer but there are other things I'm told when you do currency?

I'm 75 years old and as sharp as the head end of a Tack!
P Schnell
20
Years of Service
User Offline
Joined: 13th Feb 2005
Location:
Posted: 1st Sep 2005 02:50 Edited at: 1st Sep 2005 02:58
Forgive me if I accidently use a feature that's from VB, but I'll give it a shot...

If you want to know how to make a string into an integer and the opposite:


If you want to know ways of storing currency values, just store them as the value times 100: $99.95 = 9995 and divide by 100 INTO A FLOAT when you need to display them: Display# = 9995.0 / 100.0.

If that gives you trouble, you could try the following, but it's slow and harder to code.



I'm pretty sure DBC has the Right$ function, I'm not at my own computer.

blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 3rd Sep 2005 12:44
Btw, in DB it's Val(), not Int().

Not to say that I don't have that problem myself - It took me ages to figure out what was wrong with my piece of code when I used CStr()

[Insert extremely witty comment here] :: Add me to MSN if you like, but don't expect any big favours [unless you like VB6]. ... IDK!!

Login to post a reply

Server time is: 2025-05-22 09:14:27
Your offset time is: 2025-05-22 09:14:27