VB.NET, unlike previous versions of Visual Basic, is fully object-oriented. Also unlike previous versions, VB.NET is fully integrated with its underlying platform, the .NET Framework and the .NET Common Language Runtime. As shown in this chapter, these two factors, perhaps more than any others, influence the structure of a VB.NET program.
Any Visual Basic executable — i.e., a Windows Forms or Windows
console application — has a single application-level entry point, a subroutine named
Main must be a method
of the executed class.
The web applications (either ASP.NET applications or web service applications) that you develop with Visual Studio are not executables. They exist as dynamic link libraries (DLLs) in the system’s disk storage. ASP.NET applications may also rely on just-in-time compilation and be resident solely in memory.
Main must not only exist, it must also be:
In VB 6,
Main could be either public or private.
In VB.NET, it must be public to be visible as an entry point.
Its declaration must include the
keyword. A single Main method must be shared by all application
instances; it cannot be an instance method. Thus, all methods called
by Main must also be static (or shared) methods; a shared method is
unable to invoke an instance method.
This section focuses on executable programs. These programs exclude code libraries, as well as ASP.NET applications and ...