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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rounding values 1

Status
Not open for further replies.

reinaldo

Programmer
Joined
Mar 29, 2001
Messages
31
Location
US
method changeValue(var eventInfo ValueEvent)
DoDefault

If Deductions.Value<>&quot;&quot;and Self.Value<>&quot;&quot;
Then
Taxable.Value=Self.Value-Deductions.Value
Tax_Due.Value=Taxable.Value*.06
Percent.Value=Deductions.Value/Self.Value
endif
endMethod

Above is a method that I use on a form which has a table on it, everything works just fine, however, I would like the Taxable.Value (currency field) to round to the nearest number, as in $185.56 = $186.00 or $185.25 = $185.00.

Can I add something to the code in order to get this result?

Many thanks
Reinaldo
 
Try this.

Taxable.Value=Round((Self.Value-Deductions.Value),0)
VTJ
 
Sorry, but vtj's answer stil relies on your current machine and the standard floating point problem. In my experience, the *best* way to round numbers is to use string conversion, as outlined on my site. Please see
Hope this helps...

-- footpad
 
The method I mentioned is the &quot;easiest&quot; way to get to the result. As far as I can tell the range of values that will be used should not be compromised by the floating point problem.

Thx, VTJ VTJ
 
Status
Not open for further replies.

Similar threads

M
  • Locked
  • Question Question
Replies
2
Views
187
member 159550
M

Part and Inventory Search

Sponsor

Back
Top