Enter & Exit Events in Control Classes

  • A lot of people seem to have been having troubles with the fact that if you try to use controls in a class with the "withevents" keyword, some events (like Enter & Exit) are not included in the tracked events. I have been having some troubles with this myself & have not yet seen any particularly satisfying workarounds to this problem.

    So here is an idea I just had, I have not made any attempt yet to implement it & so have no idea how complicated doing so would be, but I thought I would just put it out here & get some feedback on the idea before I spend any real time working on it.

    The idea is to create a blank, transparent label that covers the entire form, monitor the Click event of this label, & pass it back to the normal controls on the form as necessary. Does this sound doable, or do you all think it would be merely an exercise in futility? If anyone has any better suggestions for how to work around this lack of events, please let me know.

  • Re: Enter & Exit Events in Control Classes

    Hi Andy, thanks for the reply.

    Yep, I read it but I did not quite understand it on my first reading & so was not certain if it would work for my purposes. On a second reading I think I better understand how it works, but I still do not quite think it will work for my purposes.

    So first let me see if I have this clear. Whenever the text in one of the array of textboxes changes, it points the "EventTxt" variable to that textbox, which raises the "Change" event of that variable? & then you simply check if the name of the textbox currently pointed to is the same is the name of the textbox previously pointed to & if not, act as if this were an "Exit" event for the textbox that was previously pointed to?

    So what happens when you get to the last textbox in the array & click on the button to do whatever your form does? Because clicking the button will not change any of the textboxes, so will not change the target of the "EventTxt" variable, & so will not fire the "Change" event for the "EventTxt" variable & so will not run the "on exit" commands for this last textbox. Will it?

    Anyways, what I am personally trying to do is have a textbox on a form that is invisible most of the time. If the user clicks on a button, the textbox appears with the focus set on it. The user can then enter data into the textbox. When the user attempts to move focus away from the textbox I want to check the data in the textbox, & if it is correct store this data then make the textbox invisible again. I know that I could use an input box for this, but I would much prefer having something built directly into the form (for primarily aesthetic reasons). Does anybody know of any way to accomplish this with classes, since they do not have the "Exit" or "Enter" procedures?

  • Re: Enter & Exit Events in Control Classes

    Correct the last textbox will not be able to use the other textboxes to trigger an exit. But the CommandButton does have an Enter event where you can put some checking code.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!