vbGore Free Online RPG Engine

Revolutionizing Visual Basic ORPG Development
It is currently Fri May 24, 2013 10:55 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Displaying whole numbers with 2 decimal places
PostPosted: Tue Oct 27, 2009 1:19 pm 
Wozzle Woozle Wozniak

Joined: Tue Jul 10, 2007 2:46 pm
Posts: 89
Hi all,

I am making a programm that uses currencies and i want my whole numbers to display with two decimals. For example if you have 20 dollar left I want it to show as 20.00 instead of just 20 ( or 15.50 instead of 15.5) .I suppose it is really easy to do, however the things i found don't seem to work for vb6

I hope you understand what I mean. i am using vb6 by the way,

Thanks

Love Linda


Top
 Profile  
 
 Post subject: Re: Displaying whole numbers with 2 decimal places
PostPosted: Wed Oct 28, 2009 7:00 am 
Newbie

Joined: Tue Oct 06, 2009 11:16 am
Posts: 4
You have to use the format function. Example:

Dim num As Single
num = "12.2"
MsgBox Format(num, "0.00")


Top
 Profile  
 
 Post subject: Re: Displaying whole numbers with 2 decimal places
PostPosted: Thu Oct 29, 2009 8:39 am 
Carmack's Pimple

Joined: Wed Oct 22, 2008 9:19 am
Posts: 50
If your using basic just The following code

Code:
Math.Round(application, 2)

here application is the item you want rounded. though you'll have to do your equation earliar in the line.

Or you can just use this
Code:
Format(payment, "Currency")

Payment is the application to turn to currency.
Hope that helps!


Top
 Profile  
 
 Post subject: Re: Displaying whole numbers with 2 decimal places
PostPosted: Thu Oct 29, 2009 2:14 pm 
Wozzle Woozle Wozniak

Joined: Tue Jul 10, 2007 2:46 pm
Posts: 89
Thanks

I tried the method suggested by bytelogik and that worked like a charm

Thanks you both for the help

Much Love,

Linda


Top
 Profile  
 
 Post subject: Re: Displaying whole numbers with 2 decimal places
PostPosted: Thu Oct 29, 2009 2:37 pm 
=^.^= Kitty =^.^=

Joined: Tue Mar 20, 2007 10:46 pm
Posts: 1821
Location: Sydney Australia
I'm not sure but I think there is a difference between 0.00 and #.##

Format(var,"#.##")

I think 0.00 will always append 0.00 to the end, though I am not sure.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group