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
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 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).
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 .
My guess is that your application is a command line application. Make the class Public and Shared...
Public Shared Sub Main()
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With