Infinite loop in "When receiving focus"

Hi.
Trying to set a control’s default value via code.
Attached it to Event “When receiving focus”.
Problem is: code enters infinite loop as if control

  • receives focus :ok:
  • sets the .Text = default value :ok:
  • receives focus;
  • sets the .Text = default value;
  • […]

Need to kill Base!
Is this the normal behavior for this event?
Thanks in advance.

Don’t know, what “OK” should stay for, but:
If you have added a messagebox to the event “When receving focus” following will happen:

  1. Recived focus for control.
  2. Messagebox appears and get the cursor.
  3. Messagebox has been closed and control recives focus…

So you will get a loop. You could break this by a global variable. If it isn’t set messagebox appears and variable should be set. So next time messagebox won’t appear.

1 Like