简单!为什么我的msgBox没有返回当前年份?

时间:2016-04-02 15:49:33

标签: vba excel-vba excel

我正在尝试写一个学校项目的用户年龄,并且我很难让年(Now())实际返回当前年份。

Private Sub cmdOldEnough_Click()

Dim strCalculateAge As String
Dim dtToday As Date

strCalculateAge = Right(inpAge, 4)
dtToday = Year(Now())

MsgBox dtToday

End Sub

当前代码返回日期07/08/1905。非常感谢!

1 个答案:

答案 0 :(得分:1)

您不需要Date,需要Long

Sub marine()
    Dim dtToday As Long

    dtToday = Year(Now())

    MsgBox dtToday
End Sub