MsgBox caused Form_Activated

J Trahair

Well-known member
Joined
May 14, 2008
Messages
175
Location
Spain
Programming Experience
10+
I have just discovered that MsgBox causes the form's Activated procedure to trigger. It doesn't in VB6, why the change and can I prevent it?

Thanks in advance.

Jonathan Trahair
 
What code are you running in the Activated event? You should probably be using a different event for that code.
 
It's the Activated event in the first form the user sees. The idea is to do some one-off stuff such as find and read the ini files which tell the system where things are eg. database folder, whether the terms and conditions have been read and agreed. On the first time the program is run, this process includes a file Open dialog box (for determining the path to the database folder) and also to the App.Path. However, after not finding the relevant ini file, there's a message box saying "The system has not found the application's app path.", then whilst still only half way through these procedures called from Actived, the system starts going through Activated again! Didn't happen in VB6. I could have a button to click on to start these events, but I don't want to. I don't want them in _Load, either, because the form is not visible at that point. Any ideas?
 
Activated event is not an one-off one, it's purpose is doing something every time the form is activated. Use Shown event to do something only first time form is shown.
 
Back
Top