Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculator style Textbox
Message
From
27/10/1999 15:02:07
Loren Fedje
Loren D. Fedje & Associates Ltd.
Chilliwack, British Columbia, Canada
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Calculator style Textbox
Miscellaneous
Thread ID:
00282509
Message ID:
00282509
Views:
61
There have been a number of postings regarding Calcualtor Style Numeric Textboxes.

The following is offered as a simple solution for anyone with this requirement.

This structure will allow the user to add or subtract from a present value in a TextBox simply by pressing the + or - key when the field gets focus. Or if the user enters a new value when the field gets focus, add or subtract from that new value. Eg., Enter 1000.25 press + key enter 1000.25 press any navigation key, result 2,000.50

Init of the Form

* Create a public variable
Public mvalue
mvalue=0

TextBox - Gotfocus Event

this.inputmask="" && removes the input mask until LostFocus
this.setfocus
* Allows for SelectOnEntry when the user enters the field by Mouse. Note - SelectOnEntry of the TextBox must be set to .T.

* Store the present value to a variable
if mvalue=0
mvalue=0.00
else
mvalue=this.value
endi

TextBox - LostFocus Event

* Restore the InputMask to show punctuation
this.inputmask="99,999,999.99"
* This is also in the properties of the textbox

TextBox - KeyPress Event

Lparameters nKeyCode, nShiftAltCtrl

do case
case nKeyCode=7
This.value=0.00
case nKeyCode=43 or nKeyCode=45
mvalue=mvalue+this.value
This.value=0.00
case nKeyCode=9 or nKeyCode=15 or nKeyCode=13;
or nKeyCode=24 or nKeyCode=5
This.value=mvalue+this.value
Endc
Reply
Map
View

Click here to load this message in the networking platform