Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Text field
Message
De
11/09/2002 01:08:58
 
 
À
10/09/2002 10:02:42
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00698756
Message ID:
00699193
Vues:
19
This message has been marked as a message which has helped to the initial question of the thread.
Miroslav,

Hi, I am joining this late... but I have had a similar issue, especially with currency. I created a class of
textbox for currency values... the obj_text_currency. Now, bear with me, I don't have my source code here, so I am shooting from the hip. Some of the & and ()'s might not be right, but you will get the idea:

I have a class: obj_text_currency parentclass: textbox

There are several properties, but I shall list the main ones:
obj_text_currency.ControlSource = "" && There is no control source
obj_text_currency.cMasterType = "USD"
obj_text_currency.cDisplayType = "CAN$"
obj_text_currency.nConversion = *** this is a system variable, based on where you store your exchange 
obj_text_currency.source_value = this is where you would call ControlSource
There are three main methods in the class:
 obj_text_currency.SetDisplay()
*-- only fires when a form action occurs (such as when I move to the next record, save, etc...)
*-- basically, this will only occur (or for my projects) when a oForm.REFRESH() is issued
LOCAL lnValue, lnConversion
lnValue = 0.00
lnValue = (THIS.SourceValue)
lnConvert = THIS.nConversion
THIS.Value = THIS.cDisplayType + " " + ALLTRIM(STR(lnValue / lnConvert,2))
 obj_text_currency.ConfirmDisplay()
*-- only fires when an object action occurs (i.e. we are not in readonly, must be doing an add/edit)
** just some regular code to check that we have the "CAN$" still, in the first four
** places, and that the following numbers are formatted as 99999.99 (or whatever you want).
** Then, reset the value to the verfied format.
 obj_text_currency.ReturnValue()
** Only fires when a form action save occurs
LOCAL lnValue
** same boring code to pickup the numbers from this value and
** create a decimal value again.  It also reverses the conversion
** of the current value
IF lnValue != &THIS.SourceValue
  REPLACE &THIS.SourceValue WITH lnValue
ENDIF
Now, each of the following Events/Methods call the above .ConfirmDisplay() method (overkill, I know, but I like to be safe) IF and ONLY IF the READONLY is .T.:

obj_text_currency.Click()
obj_text_currency.GotFocus()
obj_text_currency.InteractiveChange()
obj_text_currency.LostFocus()
obj_text_currency.Valid()
obj_text_currency.Refresh()

Now, I did it this way because all of my data is read only until the user is adding/editing. When the save button is used, the form save data event (for us) checks to see if there are any controls with an !EMPTY(.cDisplay) property (like this class object). It then, instead of the normal REPLACE....WITH, fires that controls obj_text_currency.ReturnValue() which will only update when there are different values.


HTH

Ric


>I have text field with ControlSource bind to table field. I would like to see the diffrent value in the field but still to save the original one.
>Ex:
>Total: US$300 (should show on the form) and should save CAN$477
>
>What is the best way of doing this?
>
>Thanks in advance
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform