Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why does RoundTo not work for me? 1

Status
Not open for further replies.

delphiman

Programmer
Dec 13, 2001
422
0
0
ZA

I have Math in my Uses clause but neither of the following will work for me. I need
dm.tblMStockInitSqMtrs.Value to be limited to TWO decimal points.

Code:
  tblMStocksqMtrs.Value := RoundTo(tblMStockHght.Value * tblMStockWdth.Value);

OR

  RoundTo(tblMStocksqMtrs.Value) := (tblMStockHght.Value * tblMStockWdth.Value);
 
tblMStocksqMtrs.Value := RoundTo(tblMStockHght.Value * tblMStockWdth.Value, -2);

Giovanni Caramia
 
And note that posting something that is essentially the same problem in a new thread is frowned upon at best and against the rules at worst, because of cluttering up the board listing and such-like. As stated, how to do it was given to you, roundTo requires two parameters.
 
gcaramia

Thanks from "downunder" Mate! For studying my problem PROPERLY!

THIS works. A star for you. :)

tblMStocksqMtrs.Value := RoundTo(tblMStockHght.Value * tblMStockWdth.Value, -2);

KempCGDR

>And note that posting something that is essentially the same problem in a new thread is frowned upon at best and against the rules at worst

If those who endeavour to make a contribution couldn't be bothered to READ the problem PROPERLEY [in the 1st thread] and as a result provide silly suggestions such as provided by earthandfire to "Just follow the example by whosrdaddy in your original post" - which effectively and obviously takes me in an un-ending circle what alternative do you suggest? OTHER than putting the same problem differently and in a different thread. Taking note that the solution by gcaramia makes SENSE at the very least :) AND IN FACT solves the problem.

Whilst YOUR advice "As stated, how to do it was given to you, roundTo requires two parameters " is as totally useless to me as a wheel-barrow in a rowing-boat - compared with that provided by gcaramia! :) :) [More advice for you on this in my thread102-1031488]
 
My understanding of your problem was that you needed to be able to return the result of a calculation correct to 2 decimal places.

Please accept my sincerest apologies if that understanding was in any way flawed.

However, based on that understanding, RoundTo(1.234, -2) = 1.23 is a perfectly corrrect and valid example to provide. You, yourself stated that 43.6743 should be 43.67.

Additionally, the solution that you praised so highly makes EXACTLY the same assumption.

 
As earthandfire just said, the only difference between the solution from gcaramia and the one from everyone else was that gcaramia's solution didn't require any thinking at all on your part. The 1.234 in the original solution is the input value, you replace it with whatever you're passing in.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top