mask for inches

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to write a mask that will allow the user to enter data that will
appear as 1-1/2" or 20-2/32" or any combination thereof the formats I have
tried are as follows;
!##-#/##\" this one runs the fractions all together

##-#/##\" this one works if all the positions are filled
however not allways are all of the positions going to filles as in 1-1/2" or
3/4" or 1"

Any help will be greatly appreceated

C.F.
 
I am trying to write a mask that will allow the user to enter data that will
appear as 1-1/2" or 20-2/32" or any combination thereof the formats I have
tried are as follows;
!##-#/##\" this one runs the fractions all together

##-#/##\" this one works if all the positions are filled
however not allways are all of the positions going to filles as in 1-1/2" or
3/4" or 1"

Any help will be greatly appreceated

C.F.

AFAIK, you can't. Input masks are simply not very flexible.

I'd suggest doing the check in the textbox's before update event,
parsing out the number and the punctuation byte by byte. Bonus: you
can calculate the decimal inches in the process.

John W. Vinson[MVP]
 
Hi C.F.,

Input masks usually more trouble than they're worth, and aren't capable
of this sort of flexibility. Instead, let the user enter anything and
then use code in the textbox's BeforeUpdate event to validate what
they've typed.

For example, you could use something like this:

With Me.ActiveControl
If .Value LIKE "#""" _
Or .Value Like "##""" _
Or .Value Like "#/#""" _
Or .Value Like "#/##""" _
...
Or .Value Like "##-##/##" ) Then
Cancel = False
Else
Cancel = True
End If
End With
 
Thank you for all of your help it would have been nice to see when the
records came up an architectual format however one work around that probably
will be acceptable is just put a leading 0 in front of the fraction ie;
01-1/4" it will work not as pretty but it will work thanks again for all of
the help its great to know you are out there to help.
C.F.
 
Back
Top