Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Oct 1, 1996

Events Not Processed Correctly in Debug Mode

Question:
I am having a problem that I hope has not been answered here before. I am experiencing different results when I run a program than I do when I use F8 to step through it. I have a text box that I want control to return to if the user enters no text and tries to go to another field. My code for the text box lost focus command is:
If NameTBX.text = "" Then
   MsgBox = "This field cannot be blank.  Please enter your name."
   NameTBX.setfocus
End IF
When I run this program, and try to tab away from the text box, I then get the msgbox continuously repeating when I hit OK, without giving me the opportunity to enter data. When I use F8, the program acts as I expect, returning the cursor to the textbox and allowing me to type. Does you have any ideas what may be going on here?

Answer:
The first thing to realize is that when you step with F8, you are bypassing the normal flow of control for window events. For instance, the code you have above should be doing exactly what you say it is...each time you try to hit a button, it will generate a lostfocus event. What you might want to do instead is to put the code to validate the box in your button. Otherwise, you will keep getting this behavior.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date