Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Input mask like a calculator for a numeric textfield
Message
 
 
To
29/07/1999 11:19:19
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00247677
Message ID:
00247712
Views:
24
>>Go to Files, Classes/VCX. Jim Booth has a textbox number class which what you are looking for. There is also a second one called Textnum2 or something like that which is a modification of Jim's. Look for #'s 803 and 806.
>
>Hey Mark!
>
>I was playing with my idea to allow users to enter an expression (like 17+23) into the text box, and I ran into a conceptual problem, maybe you can throw me some advice.
>
>I put the following code into a textbox.lostfocus()
>
>if type('eval(this.value)') = "N" then
>    this.value = eval(this.value)
>endif
>
>and I made the inputmask = "XXXXXXXXXXXX" so that any character could be entered. I created a form with my new textbox on it and a command button that had thisform.refresh in the click event.
>
>Whenever I tab out of the field, or click on the command button, mytextbox gets replaced with all X. If I remove my inputmask, then the control works correctly the first time, and then throws away everything after the first + or - sign I input into the textbox. It will also not take a * or a / after the first time.
>
>What am I missing here?

That is a cool idea. I placed the following in the LostFocus of a textbox with no mask, and it works:
if type('eval(This.value)') = "N"
   This.Value = alltrim(str(eval(This.Value)))
endif
The trick may be to always treat the before and after value as character. I also would manually bind this to a field. Perhaps in the textbox Refresh, put: this.value = somefield [convert to character if needed]. Add to the lost focus, replace somefield with this.value [convert back to numeric if needed].
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform