By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,509 Members | 1,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,509 IT Pros & Developers. It's quick & easy.

VB.NET - Problem with Main() method

P: 11
I initialize some values in main() method.
It seems the system doesn't call this method, because when I press F5 to debug, no line of this method is called.

I don't know why it happens. Please guide me how to made the system run Main(). Thanks.

Public Class BestForm

Overloads Sub Main()
Console.Writeln( "Initialize components here")
InitializeComponent()
'...
End Sub

Overloads Shared Sub Main(ByVal args() As String)
Application.Run(New BestForm())
End Sub

'...
End Class
Jul 30 '07 #1
Share this Question
Share on Google+
1 Reply


P: 78
The problem is that you're trying to overload the Main() sub, which is the starting point of the application... The Main(ByVal args() As String) gets called regardless of whether arguments are passed through to the application on startup or not, so what I suggest is to move your code from Overloads Sub Main() into Overloads Shared Sub Main(ByVal args() as String)
Jul 30 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.