'年齢計算クラス----- edit at 2004/12/30 '変数宣言を強制 Option Explicit 'プロパティはメンバー以外アクセスできない '---------- 年齢計算プロパティ ---------- Private mNenrei As Integer '年齢 Private mBirth As Date '誕生日 Private mToday As Date '対象日 '計算結果を返す Public Property Get Nenrei() As Integer Nenrei = mNenrei End Property 'データを受け取り返す Public Sub GetData(ByVal dBirth As Date, ByVal dToday As Date) mBirth = dBirth mToday = dToday '年齢計算 If CalcNenrei() = 0 Then mNenrei = 0 End Sub '年齢計算 Private Function CalcNenrei() As Integer If IsDate(mBirth) = True And IsDate(mToday) = True Then '成功 If mToday - mBirth > 0 Then mNenrei = CInt(Format$(mToday - mBirth, "yy")) CalcNenrei = 1 Else '失敗 CalcNenrei = 0 End If Else '失敗 CalcNenrei = 0 End If End Function 'クラスインスタンス Private Sub Class_Initialize() 'プロパティ初期化 mNenrei = 0 mBirth = 0 mToday = 0 End Sub