M
Malc
I am writing an invoicing system which will bill customers by weight, and in
particular by the half kilo. (or half pound in the USA)
A typical tariff may be - First 5 kilos charged at $10 and every additional
1/2 kilo charged at $1.20
Does anyone have a function that can calculate the number of half kilo over
a certain weight.
Using the example above, 7 kilos would be charged at $10 plus 4 * $1.20
The data entry screen allows for one decimal place which means I get entries
like 10.7 kilos. This would equate to - First seven kilos @ $10 and 8 half
kilos. (10.7 rounded up to 11).
This is my current function which doesn't work!
Function nohk(wt)
Dim ret, nohk1, nohk2, tenth
'calculate the number of half kilos (nohk) in the value passed
ret = InStr(wt, ".")
nohk1 = 0
nohk2 = 0
If ret <> 0 Then
nohk1 = Left(wt, ret) / 0.5
tenth = Mid(wt, ret + 1, 1)
Select Case True
Case tenth > 1 And tenth <= 5
nohk2 = 1
Case tenth > 5 And tenth <= 9
nohk2 = 2
End Select
Else
nohk1 = wt / 0.5
End If
nohk = (nohk1 + nohk2)
End Function
particular by the half kilo. (or half pound in the USA)
A typical tariff may be - First 5 kilos charged at $10 and every additional
1/2 kilo charged at $1.20
Does anyone have a function that can calculate the number of half kilo over
a certain weight.
Using the example above, 7 kilos would be charged at $10 plus 4 * $1.20
The data entry screen allows for one decimal place which means I get entries
like 10.7 kilos. This would equate to - First seven kilos @ $10 and 8 half
kilos. (10.7 rounded up to 11).
This is my current function which doesn't work!
Function nohk(wt)
Dim ret, nohk1, nohk2, tenth
'calculate the number of half kilos (nohk) in the value passed
ret = InStr(wt, ".")
nohk1 = 0
nohk2 = 0
If ret <> 0 Then
nohk1 = Left(wt, ret) / 0.5
tenth = Mid(wt, ret + 1, 1)
Select Case True
Case tenth > 1 And tenth <= 5
nohk2 = 1
Case tenth > 5 And tenth <= 9
nohk2 = 2
End Select
Else
nohk1 = wt / 0.5
End If
nohk = (nohk1 + nohk2)
End Function