Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Validating Entries In A TextBox
Message
 
À
17/10/2001 11:43:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00569648
Message ID:
00569851
Vues:
20
Instead of doing it in the data fields, do your validation when the
user clicks Save.

In your save routine, call a method to validate. This validation method
should return True/False, and the save method should decide to continue
saving based on that return value.

In the Validation routine, use this format:

LOCAL lRetVal, cMessage
lRetVal = .T.
cMessage = ""

 WITH ThisForm

  DO CASE
   CASE EMPTY(.txtMyField1.Value)
    cMessage = "The field 'MyField1' cannot be empty"
    .txtMyField1.SetFocus()

   CASE NOT BETWEEN(.txtMyField2.Value, nVal1, nVal1)
    cMessage = "The field 'MyField2' is invalid"
    .txtMyField2.SetFocus()

  ENDCASE

  IF NOT EMPTY(cMessage)
    MESSAGBOX(cMessage, 48, "Some Caption")
    lRetVal = .F.
  ENDIF

 ENDWITH

RETURN lRetVal
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform