Events Not Processed Correctly in Debug Mode

Question:
I am having a problem that I hope has not been answered herebefore. 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.setfocusEnd IF
When I run this program, and try to tab away from the textbox, I then get the msgbox continuously repeating when I hitOK, without giving me the opportunity to enter data. When Iuse 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.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS