There are just three ways to organize a VB.NET application.
But most technical articles assume that you already know all about them. If you're one of the many who still have a few questions, you could just read past the confusing bits and try to figure it out anyway. And if you have a lot of time, you can start searching through Microsoft's documentation:
- "A Module is a portable executable file, such as type.dll or application.exe, consisting of one or more classes and interfaces."
- "A Class statement defines a new data type."
- "The Structure statement defines a composite value type that you can customize."
Right, then. Any questions?
To be a bit more fair to Microsoft, they have pages and pages (and more pages) of information about all of these that you can wade through. And they have to be as exact as possible because they set the standard. In other words, Microsoft's documentation sometimes reads like a law book because it is a law book.
But if you're just learning .NET, it can be very confusing! You have to start somewhere. Understanding the three fundamental ways that you can write code in VB.NET is a good place to start.
You can write VB.NET code using any of these three forms. In other words, you can create a Console Application in VB.NET Express and write:
MsgBox("This is a Module!")
MsgBox("This is a Class")
Dim myString As String
MsgBox("This is a Structure")
This doesn't make any sense as a program, of course. The point is that you don't get a syntax error so it's "legal" VB.NET code.
These three forms are the only way to code the queen bee root of all of .NET: the object. The only element that interrupts the symmetry of the three forms is the statement: Dim myString As String. That has to do with a Structure being a "composite data type" as Microsoft states in their definition.
Another thing to notice is that all three blocks have a Sub Main() in them. One of the most fundamental principals of OOP is usually called encapsulation. (See my discussion of OOP and encapsulation by clicking here.) This is the "black box" effect. In other words, you should be able to treat each object independently and that includes using identically named subroutines if you want to.
On the next page, we dive into the most important object form, the Class, and also the Module.