Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modules being executed before the forms.

Status
Not open for further replies.

Proqrammer

Programmer
Sep 17, 2006
64
Hi there,
In vb 2003, I was able to set a module as starting point of the project and the module was being executed by the compiler before any other thing.

Now in vb 2005, you can't set a module as starting point of the project, it seems like you must choose a form instead.

My first question is, how can I set a module as starting point. I wanna have variables that are globally available in my project, and I usually define them as public variables in a module.

The second issue is, I have a module in my project, and even though I haven't set it to be executed before forms, the compiler does executed before anything else.

But sometimes for an unknown reason when I build the project, it doesn't execute the module and starts the project by starting the first form which is set in project properties.

Why is that?

 
Here try this:

Code:
Module SomeModule

    <STAThread()> _
    Public Sub main()
        MsgBox("started form sub main")
        Application.Run(YourMainForm)
    End Sub

End Module

In order to do that, open the project's properties page, uncheck "Enable Application Framework", then Sub Main will appear in the list of allowed Startup Objects.

I hope it solve the problem.
Cheers.

---
If gray hair is a sign of wisdom, then talk like a pirate ninja monkey if you get the time to get funky once a week.
Wo bu zhi dao !
 
Thanks, that was good but it disables my xp looking features, how do I turn that back?

 
hi,

you set it via code:

Code:
Module SomeModule

    <STAThread()> _
    Public Sub main()
        'Enable visual styles
        System.Windows.Forms.Application.EnableVisualStyles()
        Application.Run(YourMainForm)
    End Sub

End Module

hope it helps.

---
If gray hair is a sign of wisdom, then talk like a pirate ninja monkey if you get the time to get funky once a week.
Wo bu zhi dao !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top