Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculator style Textbox
Message
De
27/10/1999 15:02:07
Loren Fedje
Loren D. Fedje & Associates Ltd.
Chilliwack, Colombie Britannique, Canada
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Calculator style Textbox
Divers
Thread ID:
00282509
Message ID:
00282509
Vues:
60
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
Répondre
Fil
Voir

Click here to load this message in the networking platform