I'm having some trouble with date variables extracted from a masked textbox on a WinForms app.
The code which attempts to read the user input date is as follows:
DateTime datExpDate = new DateTime();
datExpDate = (DateTime)txtExpDate.ValidateText();
But I get a NullReferenceException error, even when the masked text box is deinately not Null.
The properties on the masked text box include:
Mask: 00/00/0000
Validating Type: DateTime
TextMaskFormat: IncludeLiterals
This is exactly as I have used masked textboxes on previous apps and it worked then, so why not now?
Can anyone spot what I am doin wrong please?
Best Answer
Here is the solution from MSDN:
LINK: http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.validatingtype.aspx