>************************************************** >*-- Class: _currency (e:\my work\foxpro\projects\gkkmembership\classes\baseclasses.vcx) >*-- ParentClass: textbox >*-- BaseClass: textbox >*-- Time Stamp: 10/02/14 09:57:02 PM >* >#INCLUDE "e:\my work\foxpro\projects\gkkmembership\programs\gkkmembership.h" >* >DEFINE CLASS _currency AS textbox > > > Alignment = 1 > Value = 0.00 > Height = 23 > SelectOnEntry = .T. > Width = 100 > *-- Amount entered > amount = 0.00 > *-- XML Metadata for customizable properties > _memberdata = [<VFPData><memberdata name="amount" type="property" display="Amount"/><memberdata name="amount_assign" type="method" display="Amount_Assign"/><memberdata name="uservalid" type="method" display="UserValid"/><memberdata name="allowzero" type="property" display="AllowZero"/><memberdata name="maxamount" type="property" display="MaxAmount"/><memberdata name="addcurrencysymbol" type="property" display="AddCurrencySymbol"/><memberdata name="currencysymbol" type="property" display="CurrencySymbol"/></VFPData>] > *-- Flag to indicate if zero is a valid entry > allowzero = .F. > *-- Maximum amount if greater than 0.00 > maxamount = -1 > *-- Flag to indicate whether to add the currency symbol to the value > addcurrencysymbol = .F. > *-- Currency Symbol > currencysymbol = "$" > Name = "_currency" > > > PROCEDURE amount_assign > LPARAMETERS tnAmount > this.InputMask = '' > DO CASE > CASE VARTYPE(tnAmount) = "N" > this.Amount = tnAmount > this.Value = IIF(this.AddCurrencySymbol, this.CurrencySymbol+" ", "") + ALLTRIM(TRANSFORM(tnAmount, "9,999,999.99")) > > CASE VARTYPE(tnAmount) = "C" > this.Amount = VAL(ALLTRIM(tnAmount)) > this.Value = IIF(this.AddCurrencySymbol, this.CurrencySymbol+" ", "") + ALLTRIM(TRANSFORM(tnAmount, "9,999,999.99")) > > OTHERWISE > WAIT WINDOW "Invalid value entered for Amount" NOWAIT > ENDCASE > ENDPROC > > > PROCEDURE GotFocus > SET CURSOR ON > this.InputMask = '9999999.99' > this.Amount = this.Amount > ENDPROC > > > PROCEDURE Valid > LOCAL lnAmount > DO CASE > CASE VARTYPE(this.Value) = "N" > IF this.Value > 0.00 > IF this.MaxAmount < 0.00 > this.Amount = this.Value > this.UserValid() > ELSE > IF this.Value <= this.MaxAmount > this.Amount = this.Value > this.UserValid() > ELSE > DisplayMsg("Value entered cannot be greater than $ " + ALLTRIM(TRANSFORM(this.MaxAmount, "9,999,999.99"))) > this.Amount = this.MaxAmount > RETURN False > ENDIF > ENDIF > ELSE > IF this.AllowZero .AND. this.Value = 0.00 > this.Amount = this.Value > this.UserValid() > ELSE > DisplayMsg("Invalid value entered") > RETURN False > ENDIF > ENDIF > > CASE VARTYPE(this.Value) = "C" > lnAmount = VAL(STRTRAN(STRTRAN(this.Value, ",", "") , "$", "")) > IF lnAmount > 0.00 > IF this.MaxAmount < 0.00 > this.Amount = lnAmount > this.UserValid() > ELSE > IF lnAmount <= this.MaxAmount > this.Amount = lnAmount > this.UserValid() > ELSE > DisplayMsg("Value entered cannot be greater than $ " + ALLTRIM(TRANSFORM(this.MaxAmount, "9,999,999.99"))) > this.Amount = this.MaxAmount > RETURN False > ENDIF > ENDIF > ELSE > IF this.AllowZero .AND. lnAmount = 0.00 > this.Amount = lnAmount > this.UserValid() > ELSE > DisplayMsg("Invalid value entered") > RETURN False > ENDIF > ENDIF > > OTHERWISE > DisplayMsg("Invalid value entered") > RETURN False > ENDCASE > ENDPROC > > > *-- Called by Valid event for user code > PROCEDURE uservalid > ENDPROC > > >ENDDEFINE >* >*-- EndDefine: _currency >************************************************** >Thanks Greg, I will work on this later.