views:

507

answers:

2

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?

A: 

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

Seth Spearman
+3  A: 

Hi Jaison,

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

Robert