[Listbox] Set a mask to a column ?

Stupid idea (or not ?).

After having loaded a file (that comes either by drag and drop or Paste or Open), I want to apply a date Mask to the column(s) that have “Date” in their header…

Detecting a Header with Date in its string (name) can be easy, but setting a mask seems to be tricky (or impossible).

Impossible ? Possible (if so how ?)


PS: since this is Listbox, I do not think this is possible. But I have enough to type dates illegal characters (sometimes I forget to press the shift key, sometimes I press three numbers instead of 2… etc.).

I found an answer:

In CellGotFocus:

If InStr(Me.Heading(Column),"Date") <> 0 Then Me.ActiveCell.Mask = "####-##-##" End If

Of course, this will only work for languages where the Date word is Date not other stuff, but this works for English and French (and…), and not German (Datum ?). I can eventually set a preference and a global property…

in my listbox i have an array (as a property inside the listbox class) where i put the data type of each column, so you can decide what format you aply to numeric or date columns

Either use a localized constant kDate, then it works for all languages you support:

If InStr(Me.Heading(Column), kDate) <> 0 Then

or better set the ColumnTag to DateColum (then it works for ALL languages and even if the columns get reordered):

If Me.ColumnTag(Column) = DateColum Then