Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Looking for a snazzy way
Message
 
 
To
26/07/2001 02:43:23
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00534851
Message ID:
00535779
Views:
13
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       && or ThisForm.nMask
lnDec    = This.nDecimals   && or ThisForm.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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform