msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

currency datatype returns 3 decimal places

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax
Author Message
nod



Joined: 09 Oct 2007
Posts: 10

PostPosted: Fri Oct 26, 2007 3:49 pm    Post subject: currency datatype returns 3 decimal places Reply with quote

I have the following function

Private Function calculateCost(payRate, hoursClaimed) As Currency

called like this
dim cost as currency
cost = calculate Cost(rate, hours)
cost will display a value like 119.475

Shouldn't it round up to 119.48 ?

When it gets put into an Access database field with the datatype
currency it does.

Nod

Archived from group: microsoft>public>vb>syntax
Back to top
View user's profile Send private message
Bob Butler



Joined: 04 Oct 2007
Posts: 1081

PostPosted: Thu Oct 25, 2007 8:46 pm    Post subject: Re: currency datatype returns 3 decimal places Reply with quote

"nod" wrote in message @4ax.com...
>I have the following function
>
> Private Function calculateCost(payRate, hoursClaimed) As Currency
>
> called like this
> dim cost as currency
> cost = calculate Cost(rate, hours)
> cost will display a value like 119.475
>
> Shouldn't it round up to 119.48 ?

No, VB's Currency data type supports 4 decimal places. If you want to round
to 2 decimal places you'll need to code that.

> When it gets put into an Access database field with the datatype
> currency it does.

Access data types aren't always identical to similar VB data types
Back to top
View user's profile Send private message
nod



Joined: 09 Oct 2007
Posts: 10

PostPosted: Fri Oct 26, 2007 8:04 pm    Post subject: Re: currency datatype returns 3 decimal places Reply with quote

On Thu, 25 Oct 2007 16:46:51 -0700, "Bob Butler"
wrote:

>"nod" wrote in message
>@4ax.com...
>>I have the following function
>>
>> Private Function calculateCost(payRate, hoursClaimed) As Currency
>>
>> called like this
>> dim cost as currency
>> cost = calculate Cost(rate, hours)
>> cost will display a value like 119.475
>>
>> Shouldn't it round up to 119.48 ?
>
>No, VB's Currency data type supports 4 decimal places. If you want to round
>to 2 decimal places you'll need to code that.
>
>> When it gets put into an Access database field with the datatype
>> currency it does.
>
>Access data types aren't always identical to similar VB data types
>

Thanks Bob

Nod

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Formatting string with configurable decimal places Hi, If I have this code: Dim dDouble as Double Dim strMsg as String dDouble = 0.123456789 strMsg = dDouble MsgBox strMsg I get all 9 decimal places. How do I limit it to a configurable number, akin to the %.xlf (where x is the #dp) in C++? Thanks, Alain

VTS_PVARIANT 'datatype' I'm calling a method that returns results in one of the calling parameters. The documentation shows the param as VTS_PVARIANT, where the returned value is an array of variants. in VB I have dim result as variant dim status as boolean status = GetData(resu

Strange Problem when using single datatype Hi I got a problem when using the datatype single : I tried to convert 3 string value to single and then add them together and print it out like MsgBox + + the result should be 66838.46 it works when I test r

converting Decimal to Hex Anybody have a snippet to convert very large (trillions) decimal numbers to hex?

Is Decimal a basic data type in VB6? I wanna declare a variable with the type of Decimal in VB6. But I can't find the Decimal item in the list of IntelliSense. So I doubt whether Decimal is a data type or it is defined in another library that I hadn't include into my VB project. -- Best rega
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax All times are GMT
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group