It's our system/database
I have two different values
4.95
and
6
on a button even I have
Code:
Dim x As Double, z As Double, y As Double, q As Double, v As Double
Dim f As Double, m As Double
Dim g As Double
f = 6
m = 5.45
z = gSubGst(f, 11, 10) 'done
x = gGST(f, 11) 'done
y = gCalc(f, 11, 10) 'done
q = gCalcQty(f, 11, 10, 120#) 'done
v = gSubGstQty(f, 11, 10, 120) 'done
i = gGstQty(f, 11, 120) 'done
g = gAddGSTQty(m, 10, 120)
s = gAddGST(m, 10)
Dim t1 As Currency
Dim t2 As Currency
t1 = (v + i) 'done
t2 = (x + z) * 120 'done
Debug.Print
Debug.Print
Debug.Print x & " <== x gGST"
Debug.Print z & " <== z gSubGst"
Debug.Print y & " <== y gCalc "
Debug.Print q & " <== q gCalcQty "
Debug.Print v & " <== v gSubGstQty"
Debug.Print i & " <== i gGstQty"
Debug.Print g & " <== g gAddGSTQty"
Debug.Print s & " <== s gAddGST"
Debug.Print t1 & " <== t1 "
Debug.Print t2 & " <== t2 "
and then my functions are
Code:
'function gets your gst (inc GST)
Public Function gGST(PriceIncGST As Double, GST_Div As Double) As Double
Dim g As Double
g = (PriceIncGST / GST_Div)
'g = Int(-20 * (g)) / -20
gGST = g
End Function
'function gets your gets price (inc GST) before GST
Public Function gSubGst(PriceIncGST As Double, GST_Div As Double, GST As Double) As Double
Dim p As Double
p = (PriceIncGST * GST) / GST_Div
'p = Int(20 * (p)) / 20
gSubGst = p
End Function
'calculates price (inc GST) by itself, should return same result as price
Public Function gCalc(PriceIncGST As Double, GST_Div As Double, GST As Double) As Double
Dim p As Double, g As Double
p = (PriceIncGST * GST) / GST_Div
p = Int(-20 * (p)) / -20
g = (PriceIncGST / GST_Div)
g = Int(20 * (g)) / 20
gCalc = p + g
End Function
'function gets price (inc GST) and multiplies it by qty
Public Function gCalcQty(PriceIncGST As Double, GST_Div As Double, GST As Double, QTY As Integer) As Double
Dim p As Double, g As Double
p = (PriceIncGST * GST) / GST_Div
p = Int(-20 * (p)) / -20
g = (PriceIncGST / GST_Div)
g = Int(20 * (g)) / 20
gCalcQty = (g + p) * QTY
End Function
'function gets pre gst of price inc gst then muliplies by qty
Public Function gSubGstQty(PriceIncGST As Double, GST_Div As Double, GST As Double, QTY As Integer) As Double
Dim p As Double
p = (PriceIncGST * GST) / GST_Div
p = p * QTY
gSubGstQty = Int(-20 * (p)) / -20
End Function
'function gets pre gst then muliplies by qty
Public Function gGstQty(PriceIncGST As Double, GST_Div As Double, QTY As Integer) As Double
Dim g As Double
g = (PriceIncGST / GST_Div)
g = g * QTY
gGstQty = Int(20 * (g)) / 20
End Function
'calculates price (inc GST) by itself, should return same result as price
Public Function gAddGST(PriceExGST As Double, GST As Double) As Double
Dim pG As Double
pG = PriceExGST * (GST / 100)
gAddGST = Int(-20 * (pG + PriceExGST)) / -20
End Function
'calculates price (inc GST) by itself, should return same result as price
Public Function gAddGSTQty(PriceExGST As Double, GST As Double, QTY As Integer) As Double
Dim pGQ As Double
pGQ = PriceExGST * (GST / 100)
pGQ = Int(-20 * (pGQ + PriceExGST)) / -20
gAddGSTQty = (pGQ) * QTY
End Function
I use Int(-20 * (p)) / -20 to move by 5 but when I change f falue from say 4.95 which works fine to say 6 I get a bad rounding affect.
I'm very stuck with this.