| 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: 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. |
||

