Public Function calc(aa, i)
Dim st
st = Year(aa)
mt = Month(aa)
Select Case i
Case 1
If st Mod 4 Then '非潤年
Select Case mt
Case 2
calc = aa + 27
Case 1, 3, 5, 7, 8, 10, 12
calc = aa + 30
Case 4, 6, 9, 11
calc = aa + 29
End Select
Else
Select Case mt '潤年
Case 2
calc = aa + 28
Case 1, 3, 5, 7, 8, 10, 12
calc = aa + 30
Case 4, 6, 9, 11
calc = aa + 29
End Select
End If
Case 2
If st Mod 4 Then '非潤年
Select Case mt
Case 2
calc = aa + 28 + 30
Case 1
calc = aa + 28 + 30
Case 3, 5, 8, 10, 12
calc = aa + 30 + 30
Case 7
calc = aa + 30 + 31
Case 4, 6, 9, 11
calc = aa + 29 + 31
End Select
Else
Select Case mt '潤年
Case 2
calc = aa + 29 + 30
Case 1
calc = aa + 29 + 30
Case 3, 5, 8, 10, 12
calc = aa + 30 + 30
Case 7
calc = aa + 30 + 31
Case 4, 6, 9, 11
calc = aa + 29 + 31
End Select
End If
End Select
End Function