Format in textbox

  • Thread starter Thread starter Stan Sainte-Rose
  • Start date Start date
S

Stan Sainte-Rose

Hi,
How to format a textbox to force the user to write only digits like 127-343
?

Thx

Stan
 
*Stan Sainte-Rose* tippselte am *20.10.2003 15:59* MESZ:
How to format a textbox to force the user to write only digits like 127-343
?

You could create two textboxes with a label between them.

Best regards,

Michael
 
Thanks Michael for your quicky reply :-)
But forget the - , how to force the user to write only digits (numbers) ?

Stan
 
Or you could use a regular expression which will increase
performance than adding another text box.
--------------------------------------------

Dim objRegExpr

'Create an instance of the regexp object
Set objRegExpr = New regexp

objRegExpr.Pattern = "\[0-5]{3}-[0-5]{3}"
 
*scorpion53061* tippselte am *20.10.2003 16:19* MESZ:
Case 48 To 57, 8, 13
^^ ^^ ^ ^^
Case 45 ^^

Case 46
^^

Good control, but _NEVER_ use magic numbers!!! This is a very bad
practice. Instead, define constants or use the one from the .net
Framework, like
 
*scorpion53061* tippselte am *20.10.2003 16:19* MESZ:
Case 48 To 57, 8, 13

^^ ^^ ^ ^^
Case 45
^^

Case 46

^^

Good control, but _NEVER_ use magic numbers!!! This is a very bad
practice. Instead, define constants or use the one from the .net
Framework, like

Keys.D0 for 48
Keys.Back for 8

etc.

Best regards,

Michael
 
you can test the vanue of the text on the leave event of the textbox using
string functions
ex
select case true
case t.text.length = 7
t.focus
case not t.text.indexof("-"c) = 3
t.focus
case not isnumeric(t.substring(0,3))
case not isnumeric(t.substring(4,3))

.....

if the test is no to your liking display a messagebox, statusbar message ...
and put them back in the txt until they jump to your commands ;p
 
ps you can make it a bit easyer for them:
if the input is 6 long and numeric then add the - yourself :)
 
Hi,
How to format a textbox to force the user to write only digits like 127-343
?

Thx

Stan

If you download the VB Resource Kit for .Net from Microsoft, that comes
with Component One studio which includes a masked edit box.
 
Back
Top