sequence of events

pachjo

Well-known member
Joined
Dec 12, 2006
Messages
370
Programming Experience
10+
Does anyone know what is the sequence of event when a form loads?

I have a messagebox.show call in my forms load event if a given situation occurs when the application loads.

However when the situation occurs the messagebox.show goes into an infinte loop which happens before the form is displayed?

I tried putting it in the activated event which allows the form to be displayed but the messagebox is still going into an infinte loop?

What gets called after the form is displayed after the load event?

Thanks

Sorry wrong forum!!!!
 
Last edited:
Can you post the code or a snipet? The message box alone shouldn't be able to loop much less infinitly, has to be some other interaction.
 
Here you go

VB.NET:
' verify the logged on user

If CheckUser() Then

 ' if true user is verified so call form access sub and signal to it user is verified

 SetFormAccess(True)

Else

  ' if false user verification failed so call form access sub and signal to it to disable all access

 SetFormAccess(False)

 Messagebox.Show("Application has been disabled")

End If

when it gets to the messagebox line it just keeps repeating that line, does not move back up or down just stays repeating itself?
 
Activated event isn't good for message box because it happens every time form is activated; so form activates -> messagebox activates and form deactivates -> messagebox deactivates and form activates again -> ad infinitum.
Use Load and Shown events when form is first loaded and shown. Use Activated event for something that should happen every time the form is activated (like when switching between open windows).
If you want to check something and possibly prevent application from starting you should use the application Startup event, which can be cancelled.
 
Hi, mm aplication startup event is ........ new to me!

much better to use this me thinks.

stupid question ..... how do I access it?
 
Although in this instance the shown event fits the bill! Thanks alot ;)

the application startup event however will come in handy i am sure ... when I find it, searching now :)
 
In the IDE, Project - XXXXX properties - Application - View Application Events (bottom right).
 
Back
Top