UserForm text box Date formatting

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

I have a UserForm textbox being used to capture a date. I
want to stop the user, on the UserForm, if the date is not
inputed correctly (01/01/04) or if a non-date is inputed.
Last night, I had a suggestion to use the IsDate function
but I am a newbie. Is the "Input Mask" feature, used in MS
Access, available in VBA? Can you give me suggestions on
how to use IsDate or a better solution?

Thanks.
 
userform controls have no mask or validation capabilities inherent in their
properties or methods.

Private Sub Textbox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
sStr = Userform1.Textbox1.Text
if not isDate(sStr) then
Userform.Textbox1.Text = ""
msgbox "Bad date in Textbox1"
cancel = True
end if
End sub
 
Thanks Tom, you have been big help. Dan
-----Original Message-----
userform controls have no mask or validation capabilities inherent in their
properties or methods.

Private Sub Textbox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
sStr = Userform1.Textbox1.Text
if not isDate(sStr) then
Userform.Textbox1.Text = ""
msgbox "Bad date in Textbox1"
cancel = True
end if
End sub

--
Regards,
Tom Ogivy




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top