年齢を計算する。DateDiff関数
Public Function fc_NENREI(wBirthDay As Date, wCyousaDay As Date) As Integer
'-----------------------------------------------------------------------------
' 調査日付と誕生日より年齢を計算する。
'-----------------------------------------------------------------------------
On Error GoTo Err_fc_NENREI
Dim intNenrei As Integer
intNenrei = DateDiff("yyyy", wBirthDay, wCyousaDay)
'誕生日の月日が調査日の月日より大きい場合は、年齢より1引く
If Format(wBirthDay, "mmdd") > Format(wCyousaDay, "mmdd") Then
intNenrei = intNenrei - 1
End If
fc_NENREI = intNenrei
Exit_fc_NENREI:
Exit Function
Err_fc_NENREI:
MsgBox ("fc_NENREI:" & Err.Number & " " & Err.Description)
Resume Exit_fc_NENREI
End Function