Article ID: 130355
Article Last Modified on 8/25/1999
If (M.Field <> "TEST")
Wait Window "Incorrect Value"
Return .F.
Endif
A user who enters an invalid value sees the "Incorrect Value" Wait Window
and also sees another Wait Window put up by Visual FoxPro that says
"Invalid input."
If (M.Field <> "TEST")
Wait Window "Incorrect Value"
Return 0
Endif
*--------------------------------------------------------------*
* Program: ValidTst - (C) 1995 - Microsoft Corporation *
* This program demonstrates the difference between returning *
* a value of false (.F.) when a field fails its validation *
* test versus returning a value of zero (0). Note: In order to *
* leave the input field, you MUST enter the value of TEST. *
*--------------------------------------------------------------*
frmMyForm = CREATEOBJECT('Form') && Create a Form.
frmMyForm.Closable = .F. && Disable Control menu.
frmMyForm.AddObject('txtBox1','NewTextBox') && Add 1st text box.
frmMyForm.AddObject('txtBox2','OldTextBox') && Add 2nd text box.
frmMyForm.AddObject('cmdQuit','cmdQuitButton')&& Quit Cmnd button.
frmMyForm.SHOW && Display the form.
READ EVENTS && Start event processing.
*------------------------------------------------------*
* The VALID clause for this text box will use a custom *
* error message. The only thing you will see is the *
* message box showing what you typed in. *
*------------------------------------------------------*
DEFINE CLASS NewTextBox as textbox
Visible = .T.
Left = 125
Top = 20
PROCEDURE Valid
IF (This.Value <> "TEST")
=MessageBox("You entered: "+Alltrim(This.Value))
RETURN 0 && Invalid data, do NOT return .f.
ENDIF
ENDDEFINE
*------------------------------------------------------*
* In the second text box, if you don't type in TEST, *
* You will see FoxPro's default error message (Invalid *
* input) as well as the message box. *
*------------------------------------------------------*
DEFINE CLASS OldTextBox as textbox
Visible = .T.
Left = 125
Top = 70
PROCEDURE Valid
IF (This.Value <> "TEST")
=MessageBox("You Entered: "+Alltrim(This.Value))
RETURN .F. && Returning FALSE here.
ENDIF
ENDDEFINE
DEFINE CLASS cmdQuitButton AS CommandButton && Create command button.
Caption = '\<Quit' && Caption on the command button.
Cancel = .T. && Default Cancel command button (Esc).
Left = 125 && command button column.
Top = 150 && command button row.
Height = 25 && command button height.
Visible = .T.
PROCEDURE Click
CLEAR EVENTS && Stop event processing, close Form.
ENDDEFINE
Additional query words: VFoxWin
Keywords: kbcode KB130355