penagate
Oct 3rd, 2005, 01:54 AM
When you start a program, after performing some various management tasks the Windows PE loader calls your application entry point procedure. This is where your application begins.
By default, Visual Basic assigns a "startup object", usually Form1. This is a very bad design because it leaves you with no control over the startup process. The form is loaded whether you want or not, and your code begins effectively in Form_Load().
Instead of leaving it be, go into Project -> Properties and select "Sub Main" as your startup "object". Make a new standard (.bas) module and enter the following stub in
Public Sub Main()
End Sub
Your code now begins in that procedure, before any forms or objects are instantiated. Also by using the runtime Command$() function you can retrieve the command-line arguments that are passed by the Windows loader.
By default, Visual Basic assigns a "startup object", usually Form1. This is a very bad design because it leaves you with no control over the startup process. The form is loaded whether you want or not, and your code begins effectively in Form_Load().
Instead of leaving it be, go into Project -> Properties and select "Sub Main" as your startup "object". Make a new standard (.bas) module and enter the following stub in
Public Sub Main()
End Sub
Your code now begins in that procedure, before any forms or objects are instantiated. Also by using the runtime Command$() function you can retrieve the command-line arguments that are passed by the Windows loader.