VBA 编译时提示:compile error : else without if
全部代码如下:Functionnet_sal(day,day_sal)DimsalaryAsIntegerDimtaxAsIntegersalary=day*day_sa...
全部代码如下:
Function net_sal(day, day_sal)
Dim salary As Integer
Dim tax As Integer
salary = day * day_sal
If 83500 < salary Then tax = 13505 + (salary - 83500) * 0.45
ElseIf 58500 < salary <= 83500 Then tax = 5505 + (salary - 58500) * 0.35
ElseIf 38500 < salary <= 58500 Then tax = 2755 + (salary - 38500) * 0.3
ElseIf 12500 < salary <= 38500 Then tax = 1005 + (salary - 12500) * 0.25
ElseIf 8000 < salary <= 12500 Then tax = 555 + (salary - 8000) * 0.2
ElseIf 5000 < salary <= 8000 Then tax = 105 + (salary - 5000) * 0.1
ElseIf 3500 < salary <= 5000 Then tax = (salary - 3500) * 0.03
ElseIf 0 < salary <= 3500 Then tax = 0
Else: Range("A1") = "error"
End If
net_sal = salary - tax
End Function
提示错误时,高亮显示了ElseIf 58500 < salary <= 83500 Then
请帮我看下到底哪里错了啊? 展开
Function net_sal(day, day_sal)
Dim salary As Integer
Dim tax As Integer
salary = day * day_sal
If 83500 < salary Then tax = 13505 + (salary - 83500) * 0.45
ElseIf 58500 < salary <= 83500 Then tax = 5505 + (salary - 58500) * 0.35
ElseIf 38500 < salary <= 58500 Then tax = 2755 + (salary - 38500) * 0.3
ElseIf 12500 < salary <= 38500 Then tax = 1005 + (salary - 12500) * 0.25
ElseIf 8000 < salary <= 12500 Then tax = 555 + (salary - 8000) * 0.2
ElseIf 5000 < salary <= 8000 Then tax = 105 + (salary - 5000) * 0.1
ElseIf 3500 < salary <= 5000 Then tax = (salary - 3500) * 0.03
ElseIf 0 < salary <= 3500 Then tax = 0
Else: Range("A1") = "error"
End If
net_sal = salary - tax
End Function
提示错误时,高亮显示了ElseIf 58500 < salary <= 83500 Then
请帮我看下到底哪里错了啊? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询