1. Home
  2. Computing & Technology
  3. Visual Basic
Managing Windows Forms
Forms as Software Objects in VB.NET

One change to forms in VB.NET can make them a little easier to understand. In VB 6, forms are special objects that the whole language is based on. In VB.NET, they're more like any other software object. For example, the first item in our book's Upgrade Notes: What's New in Visual Basic .NET (page 394) states:

In Visual Basic .NET, you cannot set the properties of a second form in the project without having an instance variable of the form that you want to manipulate.

What does that mean?

To use a code example, it means that in VB.NET, you must code something like,

Dim FormName as New Form

before you can code,

FormName.Property = PropertyValue

or

FormName.Method

In this example, FormName is called an instance variable. This is very different from VB 6. In VB 6 you could do something like this:

VB6 Forms

Note that in this VB 6 example, Form2 was not declared before the BackColor property was changed and the Show and Hide methods were executed.

In VB.NET, you must create an instance of any software object before you use it. The key to understanding how to use forms in VB.NET is to simply use the same coding rules that you would for other objects.

Next page >>>   Going Beyond the Book: Providing Help
Page 1, 2, 3, 4, 5
Explore Visual Basic
By Category
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic

©2009 About.com, a part of The New York Times Company.

All rights reserved.