View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld[_2_] Ron Rosenfeld[_2_] is offline
external usenet poster
 
Posts: 1,045
Default RoundDown function not working in code

On Sun, 15 Aug 2010 15:25:43 -0700 (PDT), Don G
wrote:

On Aug 15, 1:44*pm, Ron Rosenfeld wrote:
On Sun, 15 Aug 2010 12:06:47 -0700 (PDT), Don G
wrote:

I'm using Excel 2003 VBA. In the immediate window I enter


? application.rounddown(-0.775,2) *and it gives the result -0.77


In the following code


'Deal with SHEETCREDIT
* *SheetCredit = CashIn - CashDue
* *'dealing with negative sheetcredit
* *If SheetCredit < 0 Then SheetCredit =
Application.RoundDown(SheetCredit, 2)
* *'display this on the form
* *SheetsForm.DriverCreditBox.Value = Format(SheetCredit, "currency")


SheetCredit is -0.775 and the result is -0.78 *Any idea why?


I cannot reproduce your results. *In the immediate window (MS VB 6.5):

?FORMAT(application.RoundDown(-0.775,2),"currency")
($0.77)

What are the actual values for CashIn and CashDue


Ron, in the immediate window I get the same results you do, which is
what I expect and want. My concern is that running from code to put
values onto a user form the result is -0.78 not what the immediate
window gives.
In my procedure the value of CashIn is 53.4 and CashDue is 54.175 both
are declared as currency.

I appreciate your thoughts on my problem, Thanks


I've also posted a message in a few places to see if others can
explain this issue.