检查inputdate格式

任何人都知道如何检查在VBA的文本框中的inputdate格式? 我有这个代码,但我不确定输出。 用户的input格式应该是mm/dd/yyyy 。 如果没有,那么会popup一条消息:使用mm / dd / yyydate格式。

 If Not Format(txtStartDate.Value, "mm/dd/yyyy") Then MsgBox "Please use the mm/dd/yyyy date format." txtStartDate.setFocus Exit sub End If 

我只是非常不确定我所进入的。 谢谢!

  Dim regEx As New RegExp regEx.Pattern = "^[0-9]{2}/[0-9]{2}/[0-9]{4}" Dim inputstring As String inputstring = "10/2/200" If Not regEx.test(inputstring) Then MsgBox "Please use the mm/dd/yyyy date format." Exit Sub End If