Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Checking the input date value in inputbox

  Asked By: Jodon    Date: Sep 19    Category: MS Office    Views: 910
  

My problem is like this :

Sub DateChk()
Dim startdt As Date
startdt = InputBox("enter the start date ", "Start Date")

End Sub


I want to check whether the user entered a date value in the input box and if
not, then I will show an error message. But in the above code, as soon as the
user enters a wrong value, it gives "Type Missmatch". In stead of this error
message, I want to show some custom erroe message.

Can anybody help me with this please??

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Bathilda Schmidt     Answered On: Sep 19

One option would be to use

Dim startdt

Instead of Dim startdt As Date

This dims the variable as a variant. There will be no mismatch.

Then you need to do your validation of the text string

Then, when you are sure it is a valid date  you need to convert it to a date
value using

startdt=datevalue(startdt)

 
Didn't find what you were looking for? Find more on Checking the input date value in inputbox Or get search suggestion and latest updates.




Tagged: