I would aproach this problem differently: namely at the input level. Rather than telling the user that he has input incorrect info afterwards, why not disable the user from inputting incorrect info in the first place?
This can be done in several ways:
- The easiest is using the Microsoft Masked Edit Control. this control will only accept certain values in pre-specified formats (you can also custom format your values.
- The harder, but more complete (depending on your needs), way would be to code the validation routines yourself, using the KeyPress routine to capture the input as the user presses the keys, and disable certain types of input, manipulate the input dynamically (like adding "/" when entering a date without the user having to type it).
For ease of use and speed, definately try the masked edit control first. Then, if that doesn't meet your requirements, start thinking of how do a validation routine.
Of course you can always still do it the way you were thinking of (with displaying error message and all):
If txtDATE.text <> ##/##/#### Then
Like this:
Dim cArray() as String
Dim i as Integer
Dim x as integer
x = len(txtDate.text)
redim cArray(0 to x)
For i = 0 to x
cArray(i) = mid(txtDate.Text,i+1,1)
Next i
if (cArray(2) <> "/"

or (cArray(5) <> "/"

) Then
msgbox "Please use proper date format: dd/mm/yyyy"
else if (x <> 9) then
msgbox "Please use four-digit year: dd/mm/yyyy"
end if
Hope this works for you

carray = split(txtdate.text)
if ((cArray(2) <> "/"

or (cArray(5) <> "/"

) then
msgbox "please use the correct format: mm/dd/yyyy"
else if(ubound(cArray) 9) then
msgbox "please use 4-digit years: mm/dd/yyyy"
end if Take Care,
Mike