Oct 24 2007, 03:31 PM
i hope this is in the right area.
i have a piece of code which performs a calculation. The fields it takes its figures from are set to decimal with 2 decimal places. However when the calculation is performed it returns an answer allways with .00 even if the answer should have numbers after the decimal point. Whilst performing the calculations i use dim tempname as integer to hold the vaule. any ideas i really need the calculations worked out to 2 decimal places, not rounded up and .00 added
Oct 24 2007, 03:43 PM
"dim tempname as integer" makes the variable tempname store integer values (whole numbers) only. Use a different datatype instead that can store decimal numbers (single, double, currency).
Oct 24 2007, 03:51 PM
thanks i tried changing it to as double but i still get .00 for every calculation. It just rounds up or down the answer an adds .00 to it.
any other sugestions?
Oct 24 2007, 04:04 PM
If the text box for the result in the form is bound to a table column, make sure the data type in the table column can store decimal numbers.
Edited by: bome on Wed Oct 24 17:10:43 EDT 2007.
Oct 25 2007, 03:25 AM
If I need a true 2DP answer to a calculation I always use:
i.e. perform calculation - multiply result by 100 and add 0.5 (performs normal rounding) then take the integer value of this and divide by 100.
This always gives a true 2DP result and means that doing things like adding totals on an Invoice always adds "correctly"
Edited by: MartinWHughes on Thu Oct 25 5:18:27 EDT 2007.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here