Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
On Error GoTo errExit
Text1.Text = CDate(Text1.Text)
MsgBox "下一日期是:" & DateAdd("d", 1, CDate(Text1.Text))
errExit:
If Err.Number <> 0 Then MsgBox "输入日期格式有误,请重新输入!": Err.Clear
End If
End Sub
文本框为text1.text,用以下函数可得到下一天的日期。
dateadd(d,1,cdate(text1.text))
获取下一天的日期2种方法
1.dateadd(d,1,cdate(text1.text))
或者直接+1
2.cdate(text1.text)+1
Private Sub Command1_Click()
Dim a As Date
a = CDate(Text1.Text)
a = a + 1
MsgBox a
End Sub