Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What Input Mask?

Status
Not open for further replies.

Waynest

Programmer
Joined
Jun 22, 2000
Messages
321
Location
GB
Hi

I want to accept a 5 digit number with 2 decimal places. When the users enter the text box I would like input to begin immediately to the left of the decimal point and move to the right of the point when they key '.' or something to that effect.

I've currently got an input mask of ####0.00 but the users have to fill from the left with zeros and they're moaning. Ideas please?
 
Change your '0' to '9', i.e 9999.99

 
Assuming you want to see the leading zeros in a number that is less than five.two digits, set the format to 00000.00 and the input mask to !#####.##
 
It would be a nice feature to have the digits before the decimal point shift to the left when using an Input Mask (in fact, I think it should have been done that way in the first place), but Microsoft didn't make it work that way. You can't get this behavior with an Input Mask.

Do your users realize they can key leading spaces, rather than zeros, and would they be satisfied with that?

Probably not. What I'd recommend is that you get rid of the Input Mask, and use code to test the number of digits. In the AfterUpdate event for the control, get the value of the control's Text property, use InStr to find the decimal point, and from that figure out how many digits are keyed on either side. (Don't use the control's default property, because that will already have been converted to a Single or Double, and you won't be able to tell whether they keyed excess leading or trailing zeros. For example, if they keyed 1.230 when they meant 12.30, you'd want to catch that for them, but once it's been converted to a Single you can't tell that they keyed 3 decimal places.)

If you don't care about excess leading or trailing zeros, you might be able to get away with using a Validation Rule instead. I'm not sure you could write one that checked for no more than 2 decimal places, however. I couldn't think of a way to test that with Validation Rule syntax, but I'm not an expert on that syntax. Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top