Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MessageBox in a loop!!!!
Message
From
18/10/2001 01:37:26
 
 
To
17/10/2001 23:25:08
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00570063
Message ID:
00570082
Views:
20
>Hi Everyone,
>
>Can someone please tell me why in the code below the MessageBox gets caught in a continuous loop. This code is being called in the Valid event of a TextBox. Surely, I'm missing something.

If you're always returning 0 at the end, the control will never lose focus. You might want to restructure your logic as outlined below:
******************
local lnanswer, <b>lnRetVal</b>

If Empty(This.value)
  lnanswer=messagebox("First Name field cannot be blank",1,"Text Entry Error.")

  If lnanswer = 2 && If the Cancel button is clicked back out of the record.
    =Tablerevert()
    Thisform.flipenable
    Thisform.Refresh

    <b>lnRetVal = 1  && proceed to next control

  Else
    * User wants to try again:
    lnRetVal = 0</b>
   		
  Endif

<b>Else
  * Name not empty, this is OK, allow loss of focus:
  lnRetVal = 1</b>

Endif

Return <b>lnRetVal</b>
******************
It's one of my personal cardinal rules, to never use an IF statement without an ELSE - even if there's nothing to do, it encourages you to consider the flip side of the logic.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform