Differences in the Development Environment

Differences in the Development Environment

Although Visual Basic 6 shipped as part of Microsoft Visual Studio 6, it did not share a common infrastructure with its siblings C++, Visual InterDev, and Visual FoxPro. The only sharing came in the form of ActiveX components and in designers such as the DataEnvironment. Although Visual Studio 6 shipped with a common integrated development environment (IDE) called MSDev, Visual Basic 6 did not participate in MSDev and instead came with its own IDE called VB6.exe.

Visual Studio .NET ships with a single IDE that all languages built on the .NET Framework share called Devenv.exe. The Visual Studio .NET IDE is a host for common elements such as the Windows and Web Forms packages, the Property Browser, Solution Explorer (also known as the project system), Server Explorer, Toolbox, Build Manager, add-ins, and wizards. All languages, including Visual Basic .NET and C#, share these common elements.

Although the Visual Studio .NET IDE provides a common environment for different languages, the various languages are not identical or redundant. Each language maintains its own identity in the syntax, expressions, attributes, and runtime functions you use. When you write code behind a form in a common forms package such as Windows Forms or Web Forms, the code behind the form is represented by the language you are using. If you use Visual Basic, the events for the form are represented using Visual Basic syntax and have event signatures almost identical to those you are accustomed to using in Visual Basic 6. If you use C#, all of the Windows Forms event signatures appear in the syntax of the C# language.

What happened to the common tools that you have grown to love or hate in Visual Basic 6? They have all been rewritten for Visual Studio. NET, as you ll see next.

Menu Editor

Do you really want to keep using the same clunky Menu Editor that has been around since Visual Basic 1, shown in Figure 2-2? We doubt it. So you ll probably be pleased to know that you won t find it in the Visual Studio .NET environment. Instead, you create menus by inserting and editing the menu items directly on a Windows form.

Figure 2-2

Visual Basic 6 Menu Editor.

To insert a new menu in the .NET environment, you drag a MainMenu component from the Toolbox and drop it on the form. Then you select the MainMenu1 component in the component tray, below the form, and type your menu text in the edit box that says Type Here just below the title bar for your form. Figure 2-3 shows the Visual Basic .NET menu editor in action.

Figure 2-3

Visual Basic .NET s in-place menu editor.

Toolbox

The Visual Studio .NET Toolbox is similar to the Visual Basic 6 Toolbox in appearance and use. A difference you will notice right away is that the Visual Studio .NET Toolbox contains the name of each Toolbox item in addition to the icon. Also, depending on the type of project selected, the Toolbox displays a variety of tabs containing different categories of controls and components that you can add to a form or designer. For example, when you are editing a Windows Forms project, the Toolbox will contain categories titled Data, Components Windows Forms, Clipboard Ring, and General. Each tab contains ADO .NET data components such as DataSet and OleDBAdaptor; system components such as MessageQueue and EventLog; and Windows Forms controls and components such as Button, TextBox, Label, and TreeView.

A subtle difference between the Visual Basic 6 Toolbox and the Visual Basic .NET Toolbox relates to references. In Visual Basic 6, any ActiveX control you add to the Toolbox is also added as a reference within your project. The reference exists whether you use the ActiveX control on a form or not. In Visual Basic .NET, the items you add to the Toolbox are not referenced by default. It is not until you place the control on a Windows form or designer that a reference to that component is added to your project.

Because a reference to an ActiveX control automatically exists when you place the control on the Toolbox in Visual Basic 6, you can use the reference in code. For example, suppose you add the Masked Edit ActiveX control to the Toolbox but don t add an instance of the control to the form. You can write code to add an instance of the Masked Edit ActiveX control to a form at runtime, as follows:

Dim MyMSMaskCtl1 As MSMask.MaskEdBox Set MyMSMaskCtl1 = Controls.Add("MSMask.MaskEdBox", "MyMSMaskCtl1") MyMSMaskCtl1.Visible = True

If you attempt to place a Masked Edit ActiveX control on a Visual Basic .NET Toolbar, you will find that if you declare a variable of the ActiveX control type, the statement will not compile. For example, if you attempt to declare the Masked Edit control, using Visual Basic .NET equivalent syntax, the statement won t compile, as follows:

Dim MyMSMaskCtl1 As AxMSMask.AxMaskEdBox

To declare a variable of the ActiveX control type, you need to place the ActiveX control on a form. You will then be able to dimension variables of the ActiveX control type.

note

After you place an ActiveX control on a Visual Basic .NET form, you will find that you can declare variables of the control type. However, you will not be able to use Controls.Add, as demonstrated in the Visual Basic 6 code above. Controls.Add is not supported in Visual Basic .NET.

Property Browser

The Visual Studio .NET Property Browser is, for the most part, identical in terms of appearance and use to the Visual Basic 6 Property Browser. One minor difference is that the default view for the Property Browser in Visual Studio .NET is Category view, meaning that related properties are grouped under a descriptive category. Alphabetical view is also supported. The Visual Basic 6 Property Browser, on the other hand, defaults to listing properties alphabetically, although it supports a categorized view.

The Visual Studio .NET Property Browser can list all of the properties associated with a control or component. This is not the case when you are using the Visual Basic 6 Property Browser. For example, the Visual Basic 6 Property Browser cannot list object or variant-based properties. It can display properties for a limited number of objects, such as Picture or Font, but it cannot represent an object property such as the ColumnHeaders collection of a ListView control. Instead the Visual Basic 6 Property Browser relies on an ActiveX control property page to provide editing for object properties such as collections.

The Visual Studio .NET Property Browser allows direct editing of an object property if a custom editor is associated with the property or the property type. For example, the Visual Studio .NET Property Browser provides a standard Collection Editor for any property that implements ICollection. In the case of the ColumnHeaders collection for a ListView control, a ColumnHeader Collection Editor, based on the standard Collection Editor, is provided for you to edit the ColumnHeaders collection for the ListView. Figure 2-4 shows an example of editing the ListView Columns property.

Figure 2-4

Visual Basic .NET ColumnHeader Collection Editor in action.

Tab Layout Editor

Your days of clicking a control, setting the TabIndex property, and then repeating the process for the several dozen controls on your form are over. Welcome to the Visual Studio .NET Tab Layout Editor. The Tab Layout Editor allows you to view and edit the tab ordering for all elements on the form at once. To view your tab layout for the current form, select Tab Order from the View menu. A tab index number displays for each control on the form. You can start with the control that you want to be first in the tab order, and then click the remaining controls in the tab order that you want. The tab index numbers will correspond to the order in which you click the controls. Figure 2-5 illustrates the Tab Layout Editor.

Figure 2-5

Visual Studio .NET Tab Layout Editor in action.



Upgrading Microsoft Visual Basic 6.0to Microsoft Visual Basic  .NET
Upgrading Microsoft Visual Basic 6.0 to Microsoft Visual Basic .NET w/accompanying CD-ROM
ISBN: 073561587X
EAN: 2147483647
Year: 2001
Pages: 179

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net