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

Viewed 22841

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
6 Answers

Define a Public Sub Main procedure for your project. Declare it as Shared if and only if you define it inside a class.

Related