PC Review


Reply
Thread Tools Rate Thread

Decimal question in variable?

 
 
jean
Guest
Posts: n/a
 
      12th Apr 2008
Hi,
I would like to know if it exists a function to round up or down a three or
more decimal at only two,
I am not talking about the content of a cell but at the content of a variable
Ex: B = 13.34567
A = 13.35
C = A - B
I would like In this Example the result of C to be 0.
In fact I would like round up B to be 13.35.
or 13.34 if B was 13.34458

Thank you very much

Jean

 
Reply With Quote
 
 
 
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      12th Apr 2008
You can use the Round function to do what is called Banker's Rounding (if
number ends in 5 and is being rounded to the previous decimal position, the
value is rounded to the previous even digit) or Format to do what I consider
"normal" rounding (if a number ends in 5 and is being rounded to the
previous decimal position, it always rounded upward).

B = 13.34567
A = 13.3
C = Round(A - B, 2) <<<or>>> C = Format(A - B, "0.00")

If you really want the 0 value to be 0 and not 0.00, the Format version can
be changed to this...

C = Format(A - B, "0.00;;0")

Rick



"jean" <(E-Mail Removed)> wrote in message
news:B441B4BC-288D-4F8B-8A7A-(E-Mail Removed)...
> Hi,
> I would like to know if it exists a function to round up or down a three
> or
> more decimal at only two,
> I am not talking about the content of a cell but at the content of a
> variable
> Ex: B = 13.34567
> A = 13.35
> C = A - B
> I would like In this Example the result of C to be 0.
> In fact I would like round up B to be 13.35.
> or 13.34 if B was 13.34458
>
> Thank you very much
>
> Jean
>


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie Question: decimal variable type Blue Streak Microsoft C# .NET 3 12th Oct 2007 06:57 PM
setting the decimal variable to include 2 numbers after decimal point? Scott Microsoft VB .NET 1 3rd Mar 2005 10:05 PM
variable decimal places =?Utf-8?B?QmFzaWw=?= Microsoft Access Reports 1 9th Nov 2004 05:43 PM
format variable to 3 decimal Wandering Mage Microsoft Excel Programming 1 19th Jul 2004 04:53 PM
Formatting decimal variable John Microsoft Dot NET 0 30th Jun 2003 08:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:31 PM.