Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I define a Main method in a Class versus a Module?

I was just practicing some coding and noticed that I was able to use class instead of Module in VB .NET. So I replaced my module to class and I got this error message:

No accessible 'Main' method with an appropriate signature was found in 'practicevb'.practicevb

I made sure that the startup object was set correctly in Properties > Application > Startup Objects.

The error message disappears if I change it back to Module but I would like to keep it class since the other parts of my code I changed to class and didn't return and error messages.

Class Atic

    Sub Main()
        Console.WriteLine("Hello, this proram will calcaulate the quadratic forumla ax^2 + bx + c")
        Dim Quads As New Quads
        Quads.Calc()

        Console.ReadKey()

    End Sub

End Class
like image 465
nhat Avatar asked Jul 12 '11 16:07

nhat


People also ask

Should main be in a class python?

No you shouldn't. You can put your main function in the same file as a class, but there's no reason to nest it inside the class.

What is the difference between a module and a class?

What is the difference between a class and a module? Modules are collections of methods and constants. They cannot generate instances. Classes may generate instances (objects), and have per-instance state (instance variables).

What is the difference between class and module in python?

A module can have zero or one or multiple classes. A class can be implemented in one or more . py files (modules). But often, we can organize a set of variables and functions into a class definition or just simply put them in a .


1 Answers

My guess is that your application is a command line application. Make the class Public and Shared...

Public Shared Sub Main()

End Sub
like image 80
NoAlias Avatar answered Oct 06 '22 00:10

NoAlias