Monday, August 31, 2009

Classes and Objects

Classes and Objects

In VB.NET, a class is that chunk of code mentioned earlier. You've been using Classes all the time during this course. The Form you've started out with is a Class. If you look right at the top of the code window for a Form, you'll see:

Public Class Form1

The word "Public" means that other code can see it. Form1 is the name of the Class

If you look at the bottom of the coding window, you'll see End Class, signifying the end of the code for the Class.

When you place a Button or a textbox on the Form, you're really adding it to the Form Class.

When you start the Form, VB does something called instantiation. This basically means that your Form is being turned into an Object, and all the things needed for the creation of the Form are being set up for you (Your controls are being added, variables are being set up an initialised, etc).

And that's the basic difference between a Class and an Object: A Class is the code itself; the code becomes an Object when you start using it.


Note that an object is just a special kind of data. An object has properties and methods.

3 comments:

Unknown said...

Thanks for your excellent post

You really did hard work for this, I hope to write more in future

Regards
Eng. Mamun
a_mamun85@yahoo.com

Engr. Md. Siddiq Bin Nur Sourov said...
This comment has been removed by the author.
Engr. Md. Siddiq Bin Nur Sourov said...


Thank you Engr. Mamun


Engr. Md. Siddiq Bin Nur