Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I know when a textbox value has been changed?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00304787
Message ID:
00304830
Views:
26
>>>I have a textbox on a form, bound to a data field. I want to know, when the user exits the field, whether or not they changed the value of the textbox. I want to compare the new value to the previous value, NOT to the value of the field in the table, because the user may change the textbox several times while still in the screen.
>>>
>>>What's the best way to do this?
>>>
>>>Thanks!
>>
>>Hi Elyse,
>>
>>Look at the InteractiveChange event in the help file.
>
>Hi George,
>
>What about using GotFocus / LostFocus. Add a custom property to the textbox called OldVal. In GotFocus you could do this.OldVal = this.value. Then in LostFocus do:
>
if this.value == this.OldVal
>    ** No change
>else
>    ** User Changed value
>endif
>That way you're not testing on every keystroke.
>
>hth

Sure, you could do that. My instinctive reaction, however, is to go directly to the method that handles the changes. InteractiveChange doesn't fire with every keystroke, BTW. It discards the enter and tab keys, but I understand what you're getting at. Additionally, you look at the value of GETFLDSTATE(JUSTEXT(This.ControlSource)) or OLDVAL(). It is dependent on the situation, however, and these may not be approrpriate in all cases.

To paraphase my friend Dragan, "You can do anything three ways in VFP or not at all".:-)
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform