Install VFP7 and you can run those 4 lines of code in 1 line of code with the EXECScript() function. < g >
If your 1 line solution works that is great. However, I think that 1 line solution produces a mask that is 8 places wide when there are no decimals, and 9 places wide when there is a decimal. If that is your intent, cool. However, this 4-line solution always returns the same number of places. When you can put such code in the INIT of your class, IMHO, the number of lines of code should take a back seat to functionality.
I would add 2 properties to the textbox or form class, nDecimals, nMask. Then the INIT code looks like:
local lnSetDec, lnWidth, lnMask, lnDec
lnSetDec = set('decimals')
lnMask = This.nMask
lnDec = This.nDecimals
lnWidth = len(transform(lcMask))
set decimals to lnDec
This.InputMask = RIGHT(TRANSFORM(lnMask/INT(10**(lnDec-1)), '@T'), lnWidth)
set decimals to lnSetDec
Now you have a reusable class that is quite generic.
Mark McCasland
Midlothian, TX USA