I tried to start my application off with module1, just as a test to see if modules worked the same. Here is my module
Module Module1
Sub main()
Dim frm As New Form1
frm.Show()
End Sub
End Module
Error 1 Protected types can only be declared inside of a class. C:\vs2005Projects\ModuleAttampt\ModuleAttampt\My Project\MyApplication.Designer.vb 22 29 ModuleAttampt
Error 2 'Module1' is a type in 'ModuleAttampt' and cannot be used as an expression. C:\vs2005Projects\ModuleAttampt\ModuleAttampt\My Project\MyApplication.Designer.vb 35 27 ModuleAttampt
Sub main()
Application.Run(New Form1)
End Sub
Same two errors.
When I chose sub main as the starting element instead of module1, I got this error:
Error 1 'Sub Main' is declared more than once in 'ModuleAttampt': ModuleAttampt.Module1.Main(), ModuleAttampt.My.MyApplication.Main(Args() As String)
But it is declared only once.
Module Module1
Sub Main()
Application.Run(New Form1)
End Sub
End Module
The documentation clearly states:
The Main procedure is the "starting point" for your application — the first procedure that is accessed when you run your code. Main is where you would put the code that needs to be accessed first. In Main, you can determine which form is loaded first when the program is started, find out if a copy of your application is already running on the system, establish a set of variables for your application, or open a database that the application requires. There are four varieties of Main: .....
Can somebody tell me how to open a form from sub Main
dennist

Can't start appliction with sub main
bmcilvaine
dennist
micca46899
dennist
hendyb
I tried
<STAThread()> _
Shared Sub Main()
' Starts the application.
Application.Run(New Form1())
End Sub
and the shared word was underlined, saying methods in a module cannot be declared shared.
dennist
_MS
<STAThread()> _
Shared Sub Main()
' Starts the application.
Application.Run(New Form1())
End Sub
Jaime Atiles
McGanahan Skejellyfetti
If you start a project with a form, you can have "enable application framework" and then you can choose "enable xp styles".
If you start a project with Sub Main in a module, you can't have "enable application framework" then you can't choose "enable xp styles".
Then you must add (in the sub main) :
System.Windows.Forms.Application.EnableVisualStyles()
Dominique
element__
net2020
You can use a sub main() to start your application by disabling the application framework in the Project Designer:
- Double-click the My Project node in Solution Explorer -or- select Project->Properties
- Uncheck the "Enable application framework" checkbox
- Select Sub Main() as the startup object.
The error message we're returning here is pretty inpenetrable. I'll work with the feature team to see if we can provide more actionable feedback.
Thanks!
Joe Binder
Visual Basic Team
zinc