Additional Information:
- Im using Visual Studio 2008 (VB)
- I have experience with C#
I cant see where to define the Main Sub, here is my problem:
I created a WindowsApplication in Visual Studio, it created a Form for me, when i click 'View Code', something like this appears.
Public Class Form1
End Class
wups, where is the Main Sub and where is the designer generated code?
And the next problem is, that when I delete the Form1
, an error occurs which says that the MainForm
isnt set. Double Clicking the error leads me to an Application.Designer.vb
, which looks like following:
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:2.0.50727.4927
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
'NOTE: This file is auto-generated; do not modify it directly. To make changes,
' or if you encounter build errors in this file, go to the Project Designer
' (go to Project Properties or double-click the My Project node in
' Solution Explorer), and make changes on the Application tab.
'
Partial Friend Class MyApplication
开发者_高级运维 <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Public Sub New()
MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
Me.IsSingleInstance = False
Me.EnableVisualStyles = True
Me.SaveMySettingsOnExit = True
Me.ShutdownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
End Sub
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.WindowsApplication1.Form1
End Sub
End Class
End Namespace
I want to define my own Main Entry Point, is there a way to do so?
You need application events.
go to Project Properties or double-click the My Project node in Solution Explorer, choose application tab.
There you can choose the application startup form.
To more sophisticated scenarios you need to click on "View Application Event".
This will create an ApplicationEvent.vb
At this class partial you can choose how to startup.
Example:
Protected Overrides Function OnStartup(ByVal eventArgs As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) As Boolean
Me.MainForm = New Form2
Return MyBase.OnStartup(eventArgs)
End Function
Create a console application and show your form using Form.show in the Main() method.
精彩评论