本帖最后由 luanjinling 于 2011-9-5 11:29 编辑
不仅学到了编程知识,还学到了个税计算知识
谢谢了!
如果把诸多ElseIf LeiBie 语句改为select case 中case LeiBie 语句,整个程序结构将更加清晰易读。特修改如下:
Function GeShui(ShouRu As Double, FeiYong As Double, Optional LeiBie As Integer = 1) '个人所得税函数,ShouRu为应税收入,FeiYong为当地费用扣除标准 'LeiBie为选择参数,1为计算正常月度个人所得税,2为年终奖,-1为税后收入倒算个税,-2为年终奖税后收入倒算个税 Dim FenJie, ShuiLv, SuSuan FenJie = Array(0, 500, 2000, 5000, 20000, 40000, 60000, 80000, 100000) '收入分界 ShuiLv = Array(0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45) '各档税率 SuSuan = Array(0, 25, 125, 375, 1375, 3375, 6375, 10375, 15375) '各档扣除数 If FeiYong < 0 Then FeiYong = 0 ShouRu = ShouRu - FeiYong If ShouRu <= 0 Then GeShui = 0 Exit Function End If select case LeiBie case 1 For i = 8 To 0 Step -1 If ShouRu > FenJie(i) Then GeShui = ShouRu * ShuiLv(i) - SuSuan(i) Exit For End If Next case 2 For i = 8 To 0 Step -1 If ShouRu / 12 > FenJie(i) Then GeShui = ShouRu * ShuiLv(i) - SuSuan(i) Exit For End If Next case -1 For i = 8 To 0 Step -1 If ShouRu > FenJie(i) - FenJie(i) * ShuiLv(i) + SuSuan(i) Then GeShui = (ShouRu * ShuiLv(i) - SuSuan(i)) / (1 - ShuiLv(i)) Exit For End If Next case -2 Then For i = 8 To 0 Step -1 If ShouRu > FenJie(i) * 12 - GeShui(FenJie(i) * 12, 0, 2) Then GeShui = (ShouRu * ShuiLv(i) - SuSuan(i)) / (1 - ShuiLv(i)) Exit For End If Next case else End Select GeShui = Round(GeShui, 2) End Function
|