Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Visual Basic (Classic) FAQ

New Language Features

A simple explanation of Classes and Instances by ThatRickGuy
Posted: 13 Jan 05 (Edited 15 Sep 06)

Think of a class as a blue print for a house.

Although you have the plans for the house, it doesn't physically exist. You can't live in it, you can't open the front door, you can't do anything with it.

Think of an instance as the house that is built from those blue prints. It physically exists. You can now .MoveIn() and .ThrowAParty()

There are somethings you can do without an instance. These are called "Shared" methods in VB.Net. In the house example, think of these like .getSquareFootage() and .getNumberOfBathrooms(). Since the blueprints describe the house, we know how many square feet and bathrooms there will be even before the house is built.

One of the most obvious changes from VB6 to .Net is the Form. In VB6 the form object would automatically create itself, and you could just use Form.Show. In .Net the form you create is a class. It is a description of what that object will be when it's instantiated.

The first step in showing a form now is to Instantiate the form. To instantiate an object means to assign it memory, luckily this is done for us by using the "New" keyword.

Dim myform as New Form1

Now that the form object exists in memory, we can use it's functions.


One of the next big changes from VB6 is scope. In VB6 you could access myform from anywheres. But if we go back to the house example, you can build two houses from the same blue prints. The houses will be physically identical, but will have different addresses. The same is true for forms in VB.Net. If you declare myform as New Form1 in two different places, you will have two identical forms at two different addresses. If you want to use one of those forms, you need to have access to that specific object. This FAQ: FAQ796-5773 goes into more depth on how to work between forms.


Back to Visual Basic (Classic) FAQ Index
Back to Visual Basic (Classic) Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close