Round Up (1 Viewer)

Harry Taylor

Registered User.
Local time
Today, 16:42
Joined
Jul 10, 2012
Messages
73
Hi,

I have a Cost field & and a calculated Price field generating a sell price ( calculation *1.16 / .75 )

How do I add to the expression [Cost]*1.16/0.75 to round UP to the nearest 50

E.G. - My cost is 1119.35 generating a sell price of 1731.26. I want this to be 1750

I hope this makes sense

Any help would be appreciated
 

ebs17

Well-known member
Local time
Today, 17:42
Joined
Feb 7, 2020
Messages
1,960
Code:
Function CeilingToMultiple(ByVal value As Double, ByVal multiple As Integer) As Double
    CeilingToMultiple = -Int(-value / multiple) * multiple
End Function
Code:
? CeilingToMultiple(1731.26, 50)
 1750
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 10:42
Joined
Feb 28, 2001
Messages
27,277
In general, you convert the sell price to "block" integers by dividing the sell price by 50, then using something like CLNG to make it an integer, then add 1 to it, then multiply it by 50 and convert it to whatever data type you need it to be, like DOUBLE or CURRENCY.
 

Harry Taylor

Registered User.
Local time
Today, 16:42
Joined
Jul 10, 2012
Messages
73
Thank you all,

I understand the principle and should be ok from here. Again, your help is very much appreciated :)
 

Users who are viewing this thread

Top Bottom