The other way to predetermine the input type is setting an initial value. If you set a textbox value to 0 at design time, a user can't change the value to a text. Set it to a date, and it remains a date. So very many such restrictions work even without any inputmask. And it's even more restrictive or precise, if you use controlsource to bind the control to a tanle field. Table fields are strongly typed by definition.
There also are specific controls for numbers, eg spinner.
Inputmasks are specifically helpful about conditions Mike showed within a string value otherwise allowing all cahracters.
Then you can also act on any single input with InteractiveChange() event. For example let's tame the behavior of maxlength. First of all, if you set a textbox.maxlength=3 you can only enter three characters, that's already another tip. The textbox will automatically tab to the next control if you rreach maxlength. That may not be what you want. You can SET CONFIRM ON to stay in the textbox, but next keydown will just change the last letter and you get an annoying ping sound.
Let's do that better with InteractiveChange:
Code:
#Define maxlen 3
IF LEN(ALLTRIM(this.value))>maxlen
this.Value = LEFT(ALLTRIM(this.Value),maxlen)
this.SelStart=maxlen-1
ENDIF
Now the same behavior without the pinging.
Or this one:
Code:
#Define maxlen 3
IF LEN(ALLTRIM(this.value))>maxlen
this.Value = RIGHT(ALLTRIM(this.Value),maxlen)
this.SelStart=maxlen
ENDIF
Now what you type shifts previous value out.
You can do pretty much anything you want, filter out unwanted input, change color to red to visually warn the user etc. etc.
Bye, Olaf.