Thank you, my intention was to allow the user to type the day part of
the day and allow the auto expand to fill in the rest to reduce
typing. I presume I will have to be happy with a date picker control
You could probably do something fancy with the Change event:
Public sub txtSomeDate_Change()
dim varTemp as variant ' allow coercion
' get a temporary copy
vartemp = txtsomedate.text
' if it's a number, attempt to expand it
if isnum(varTemp) then
' is it a valid day-of-a-month?
if 0 < vartemp and vartemp < 32 then
' try adding today's month and year after it
vartemp = vartemp & format(Date(), "\/mm\/yyyy")
' put it back in the control
txtSomeDate.Text = varTemp
' and highlight the bit we added
txtSomeDate.SelStart = Len(varTemp-8)
txtSomeDate.SelLength = 8
End if
Else
' carry on with other inputs
End If
End Sub
you need to be pretty clear about how you are going to interpret the user's
input and what to do with it. It's not hard to get badly in the way of
typing something quite legal.
HTH
Tim F