I'm writing an app which is kind of a small payroll system that calculates NI but not tax. I've just got round to calculating the NI from equations that have been given to me by the tax office. The problem is my result is always 5p less than it should be. Can anybody see why??
curPercent = 10
curUEL = 27820
curEmpThreshold = 3952
Sample results :Code:Dim rsNI As ADODB.Recordset Dim curGrossPay As Currency Dim curEmpThreshold As Currency Dim curUEL As Currency Dim curPercent As Currency Dim curCalc1 As Currency Dim curCalc2 As Currency Dim curResult As Currency ' Get NI Data from DB Set rsNI = New ADODB.Recordset rsNI.CursorType = adOpenForwardOnly rsNI.Open "National_Insurance", conCrowd, , , adCmdTable If not rsNI.EOF Then curGrossPay = CCur(txtGross.Text) curEmpThreshold = CCur(rsNI!NEL_Annual) curUEL = CCur(rsNI!UEL_Annual) curPercent = CCur(rsNI!Employee_Rate) End If rsNI.Close Set rsNI = Nothing ' Calculate Employee Contribution curCalc1 = curEmpThreshold / 52 ' As pay period is 1, round down to whole pounds curCalc1 = Fix(curCalc1) curCalc1 = curGrossPay - curCalc1 If curCalc1 <= 0 Then ' No NI Contribution Exit Sub End If curCalc2 = curUEL / 52 ' Round up to whole pounds curCalc2 = Format(curCalc2, "######.##") If InStr(CStr(curCalc2), ".") <> 0 Then ' Not a whole pound, Round up curCalc2 = Fix(curCalc2) curCalc2 = curCalc2 + 1 End If curCalc2 = curGrossPay - curCalc2 ' If negative treat as zero If curCalc2 < 0 Then curCalc2 = 0 curResult = ((curCalc1 - curCalc2) / 100) * curPercent
Gross : 280 Result : 20.45 I Get : 20.40
Gross : 310 Result : 23.45 I Get : 23.40
Gross : 325 Result : 24.95 I Get : 24.90
Gross : 400 Result : 32.45 I Get : 32.40
Any help will be greeted with open arms!!!![]()




