locked
Where To Put Initialization Code RRS feed

  • Question

  • I keep some interface settings in a local MSaccess database.  The question I have is: where should I put the code that queries that database and sets up some initial variables so that they will be available to the entire application as needed. 

    Would I just have to add a module to my solution to do this, and put the code that initializes in there?  If that's the answer, I can't figure out what sort of sub to put my database query code in.

    Thanks for any pointers.

    Wednesday, February 8, 2006 6:17 PM

Answers

  • How about in the MyApplication_Startup() routine?

    It's in the ApplicationEvents.vb file, which you can 'enable' by going to My Project => Application and selecting the View Application Events button.

    Wednesday, February 8, 2006 6:59 PM

  • It can be called by any number of your startup Form events or from a Sub Main routine in a standard module (if that is the entry point of your application). It can also be called from the Application Startup event, which might be the best choice.
    Wednesday, February 8, 2006 7:03 PM

All replies


  • You can use either a standard or class module. If you use a standard module, just create a Public Sub (or Function if you need to return a value) and call it during application start up.

     

    Wednesday, February 8, 2006 6:33 PM
  • Paul, Thanks.  Forgive me for my cluelessness, but how would I call it during the application startup?  Thanks again.
    Wednesday, February 8, 2006 6:35 PM
  • How about in the MyApplication_Startup() routine?

    It's in the ApplicationEvents.vb file, which you can 'enable' by going to My Project => Application and selecting the View Application Events button.

    Wednesday, February 8, 2006 6:59 PM

  • It can be called by any number of your startup Form events or from a Sub Main routine in a standard module (if that is the entry point of your application). It can also be called from the Application Startup event, which might be the best choice.
    Wednesday, February 8, 2006 7:03 PM