Simple! Why is my msgBox not returning the current

2019-08-29 04:52发布

I am trying to write verify the users age for a school project and am having troubles getting the Year(Now()) to actually return the current year.

Private Sub cmdOldEnough_Click()

Dim strCalculateAge As String
Dim dtToday As Date

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

MsgBox dtToday

End Sub

The Current code returns the date 07/08/1905. Many thanks!

1条回答
干净又极端
2楼-- · 2019-08-29 05:43

You don't need a Date, you need a Long:

Sub marine()
    Dim dtToday As Long

    dtToday = Year(Now())

    MsgBox dtToday
End Sub
查看更多
登录 后发表回答