Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of Program.cs in VB.NET

What is the equivalent of Program.cs in VB.NET WinForms application?

I need to move my .CS app to VB.NET.

As I do not have forms in my WinForms project in Program.cs I do the following:

Application.Run(new MyForm(parm1, parm2);

How to move this code in VB.NET?

Thanks

like image 446
MaiOM Avatar asked May 10 '12 13:05

MaiOM


People also ask

What is Program cs in Visual Studio?

Program.cs is the entry Point for application. Like any application the execution of Application starts from public static void Main(string[] args){} This Program. cs creates the application Host. It configures the setiings file like appsettings.

How do I open the cs Program in Visual Studio?

If your program code is already in a Visual Studio project, open the project. To do so, you can double-click or tap on the . csproj file in Windows File Explorer, or choose Open a project in Visual Studio, browse to find the . csproj file, and select the file.

What is Program cs in .NET Core?

ASP.NET Core apps created with the web templates contain the application startup code in the Program. cs file. The Program. cs file is where: Services required by the app are configured.

How do you call a method in cs Program?

cs you just add a method there, you need to make it static since the Program class is static . To call it from a button, just double click the button in the designer and an event handler is created. The same principle applies if you put the code in another file.


2 Answers

By default, VB.NET applications use the mysterious Windows Application Framework which means that the build process adds an entry point for you which automatically runs whichever form you use as the main form. You can access these settings via Project Properties > Application > Windows application framework properties.

If you don't want to use the framework, un-check the Enable application framework check box and then select that you want to use Sub Main as your Startup object. Then you can create a module with a Public Sub Main method which will be the entry point to the application, just like in Program.cs in C#.

like image 153
Steven Doggart Avatar answered Oct 05 '22 07:10

Steven Doggart


It doesn't matter whether it's Program.cs or YouNameIt.cs.

The default entry point is Main().

This code should work, unless you have another entry point (Can be specified in project settings).

Shared Sub Main()     
   ' Starts the application.
     Application.Run(New Form1())
End Sub
like image 44
animaonline Avatar answered Oct 05 '22 05:10

animaonline