Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Click or keypress
Message
De
09/02/2006 08:10:31
 
 
À
09/02/2006 07:57:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 8
Database:
Visual FoxPro
Divers
Thread ID:
01094948
Message ID:
01094953
Vues:
7
>hi all,
>
>any new way to write this code under , and at click or keypres is better
>
>IF thisform.text2.value=ALLTRIM("Residential") AND thisform.text1.Value <   1    OR thisform.text1.Value>5
>        =MESSAGEBOX("out of range")
>            thisform.text1.SetFocus
>ENDIF
>IF thisform.text2.value=ALLTRIM("Business") AND thisform.text1.Value < 1 OR     thisform.text1.Value>4
>       =MESSAGEBOX("out of range")
>     thisform.text1.SetFocus
>ENDIF
>
>thanks.

1. No point in trimming "Residential" etc. but there IS for the text you compare it with
2. Putting all within With ... Endwith makes it more readable and saves time
3. You DO realise that the IF ... AND will be evaluated BEFORE the OR? I don't know what the criteria are here:

a) If this and that .... or the other
b) If this and .... that or the other

4. I don't know where your cursor is when you want to do this test. If it's on a field on the form then the code could go in the .Valid() event or .LostFocus(). But, if it's in a valid event you can't use SetFocus(), you can only return T/F or a tab index. e.g. If you want it to stay on Text1 then issue F or 0; if you want it to jump forward, say, 2 fields, then return 2
With thisform
IF  ALLTRIM(.text2.value) = "Residential" ;
AND .text1.Value <   1 ;   
OR  thisform.text1.Value > 5
    =MESSAGEBOX("out of range")
    .text1.SetFocus
ENDIF
IF  ALLTRIM(.text2.value) = "Business" ;
AND .text1.Value < 1 ;
OR  thisform.text1.Value > 4
    =MESSAGEBOX("out of range")
    .text1.SetFocus
ENDIF
EndWith
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform