Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fsize()
Message
From
02/11/1999 13:37:46
 
 
To
02/11/1999 09:30:39
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00285443
Message ID:
00285595
Views:
20
Hi Mike.

>> I'd like to be able to set an inputmask on "Numeric" fields using <<

Does this work for you?
LOCAL lcAlias, lcField, lcType, laFields[1], ;
      lnElement, lnRow, lcIntegerPart, lcDecimalPart

WITH This
  IF ! EMPTY( .ControlSource )
    IF EMPTY( .InputMask )
	*** Only set the inputmask for numeric and character fields
	*** and check the data type of the underlying field so we
	*** can set it appropriately
	lcType = TYPE( This.ControlSource )
	IF INLIST( lcType, 'C', 'N' )
 	  *** Parse the alias and the field name from the ControlSource
	  lcAlias    = JUSTSTEM( .ControlSource )
	  lcField    = JUSTEXT ( .ControlSource )
	  *** Don't attempt to check the properties of the underlying
	  *** field if we are bound to a form property
	  IF UPPER( lcAlias ) # 'THISFORM'
	    *** format the field if it is character
	    IF lcType = 'C'
		.InputMask = REPLICATE( 'X', FSIZE( lcField, lcAlias ) )
	    ELSE
		AFIELDS(laFields, lcAlias)
		lnElement = ASCAN(laFields, UPPER(lcField))
		IF lnElement > 0
		   lnRow = ASUBSCRIPT(laFields, lnElement, 1)
		   lcIntegerPart = REPLICATE('9', laFields[lnRow, 3] - laFields[lnRow, 4] - 1)
		   lcDecimalPart = REPLICATE('9', laFields[lnRow, 4])
		   .InputMask = lcIntegerPart + '.' + lcDecimalPart
		ENDIF
    	    ENDIF
	 ENDIF
      ENDIF	
    ENDIF
  ENDIF
ENDWITH			
Marcia
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform