Limit Textbox inputs to Format

From: Brian Stigler (bkstigler_at_usa.net)
Date: 02/18/04


Date: Tue, 17 Feb 2004 18:20:53 -0800

Here's an interesting one... I haven't had any luck coming up with a slick
solution...

I have a set of textboxes on a form. Each of the textboxes has an
associated format string for numeric input.
txtFormat(0)="0.00"
txtFormat(1)="0.0"
txtFormat(2)="0.000"
etc.

The associated formats can be different from run to run so I can't hard code
a format to a particular textbox... I just read the format string from an
XML input file.

Here's my question:
I would like to limit the user to numeric inputs only.... (no characters)
and also limit them to numbers in the format specified for each textbox.

So for example... if a user inputs 2a, the system would beep and the textbox
background would maybe flash red for a brief second indicating that the
input is invalid. Also, the character "a" would not be displayed since it
is an invalid character. (This eliminates the option of using the LostFocus
event since I would like an immediate response to the user.)

For valid numeric inputs... the user could input 1.23 and no more for a
textbox with a format of "0.00". Trying to type "1.234" would again yield a
beep and a red flash and the "4" would not be displayed since it exceeds the
format limit.

Any suggestions???

Thanks a bunch as always.
Brian



Relevant Pages

  • Re: Number formats & text align
    ... Picky, picky client, eh? ... Don't know any way around that other than perhaps coding the Format event to ... RightMargin property of the textbox by an amount that will cause the ... > alignment about 1/2 character to the right (still enough for my client to ...
    (microsoft.public.access.reports)
  • Re: Flow control
    ... > The Date TimePicker unfortunately does not allow 00 in the hours position, ... To supply an hours format, I would like the first character to increment ... Is it possible to set an input filter in a textbox in visual basic, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Use TextBox Text As Function Name!
    ... the text in the TextBox changes to "<the name of the ... > OptionButton that was checked just before the selection change>2<the ... You have some design issues here. ... using the most common format. ...
    (microsoft.public.vb.general.discussion)
  • Re: Newbie question on formatting a field in table design
    ... Each department field is set to the default format ... multiplies the number entered by 100 and adds the "%" sign. ... right of the textbox, then store the number that way and do the ... normalized table design would convert your 11 ...
    (comp.databases.ms-access)
  • Re: Custom Cell Format problem
    ... I am having trouble with this "raw" TextBox. ... when I paste the contents of the UserForm into a new row on the sheet ... I have raw data in the format of 3 numbers, ...
    (microsoft.public.excel.programming)