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.
myform.show()
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.