Jaison
Jaison

Reputation:

Validation in text box vba

i have vba textbox where i can take the validation

which should only take number and accept UPTO 8 character length

how can i put a validation which will take only this?

Upvotes: 0

Views: 2269

Answers (2)

Sesame
Sesame

Reputation: 3410

Building on Seth's answer, I have a bit to add:

00000000;0;_ will give you an input mask that REQUIRES 8 numbers...

You'll want to use 99999999;0;_ which will be a mask that allows UP TO 8 numbers.

An example of usage would be:

Me.txt1.InputMask = "99999999;0;_"

Also, the second section of this mask (the 0 following the semi-colon) is used to define whether you want to store the mask characters in the table. In your case, you do not have any mask characters, so this can be left blank (but it's ok as 0, too!). It is used for things like SSN or Phone Numbers which have extra characters in addition to the ones entered.

Hope this helps,

Robert

Upvotes: 3

Seth Spearman
Seth Spearman

Reputation: 6780

Put the following in the Input Mask property of the text box.

00000000;0;_

The underscore is the placeholder character. REplace it with something else if you like.

Seth

Upvotes: 0

Related Questions