I never suggest using Textboxes or Inputboxes to accept dates. So many things can go wrong. I cannot even suggest using the Calendar Control or the Date Picker as for that you need to register the mscal.ocx or mscomct2.ocx and that is very painful as they are not freely distributable files.
Here is what I recommend. You can use this custom made calendar to accept dates from the user
PROS:
- You don’t have to worry about user inputting wrong info
- You don’t have to worry user pasting in the textbox
- You don’t have to worry about writing any major code
- Attractive GUI
- Can be easily incorporated in your application
- Doesn’t use any controls for which you need to reference any libraries like mscal.ocx or mscomct2.ocx
CONS:
Ummm…Ummm… Can’t think of any…
HOW TO USE IT (File missing from my dropbox. Please refer to the bottom of the post for an upgraded version of the calendar)
- Download the
Userform1.frm
andUserform1.frx
from here. - In your VBA, simply import
Userform1.frm
as shown in the image below.
Importing the form
RUNNING IT
You can call it in any procedure. For example
Sub Sample()
UserForm1.Show
End Sub
SCREEN SHOTS IN ACTION
NOTE: You may also want to see Taking Calendar to new level