Changes to Controls

function OpenWin(url, w, h) { if(!w) w = 400; if(!h) h = 300; window.open(url, "_new", "width=" + w + ",height=" + h + ",menubar=no,toobar=no,scrollbars=yes", true); } function Print() { window.focus(); if(window.print) { window.print(); window.setTimeout('window.close();',5000); } }
Team-Fly    

Special Edition Using Microsoft® Visual Basic® .NET
By Brian Siler, Jeff Spotts
Table of Contents
Appendix B.  Tips on Conversion from VB6


The way some controls work has been changed since VB6. This section lists some of these controls and the things about them that have changed.

Default Properties

In VB6, most controlsand other objects supported the use of default properties. For example, the default property of a TextBox control was the Text property; therefore, you could set a TextBox control's Text property with the code txtLastName = "Hajek" instead of the longer (but equivalent) txtLastName.Text = "Hajek". Visual Basic .NET no longer supports the use of default properties; you must explicitly specify the name of the property you want to set or retrieve in code.

Tip

There is one exception to this guideline. Objects that take arguments do support the use of a default property. For instance, a Recordset object (in ADO) supports the default property of Fields; therefore, rsSales.Fields("qtr1") and rsSales("qtr1") are equivalent.


Text Property Replaces Caption Property

In VB6, the Caption property defined the text that appeared in a Label control, in the title bar of a form, and on the face of a button, among other objects. In Visual Basic .NET, the Caption property of Label controls, Button controls, Forms, and several other objects has been replaced by the Text property.

Button Control Replaces CommandButton Control

The CommandButton control from previous versions of Visual Basic is now called the Button control. Its functionality is the same; however, as mentioned previously, its Text property replaces the CommandButton control's Caption property.

GroupBox Control and Panel Control Replace Frame Control

In previous versions of Visual Basic, the Frame control was used as a container to create logical groupings of controls (such as option buttons). In Visual Basic .NET, this functionality is provided by the new GroupBox and Panel controls. The main difference between the two is that the GroupBox control has a visible border and may include a caption (by setting its Text property). The Panel control is invisible to the user at runtime and cannot have a caption, but it provides grouping functionality nonetheless.

The Timer Control

In VB6, the event that the Timer control fired at regular intervals was called the Timer event. In Visual Basic .NET, the Timer control's Timer event has been replaced by the Tick event, which is also fired at regular intervals as defined by the Timer control's Interval property.

The MainMenu Control

In previous versions of Visual Basic, you used the Menu Editor to create Menu controls, which provided menus for your forms. Visual Basic .NET provides the MainMenu control, which you can add to a form from the Toolbox just like any other controls. You can then manipulate the control at design time to add menu and submenu items to the form. The MainMenu control is discussed in detail in Chapter 10, "Understanding Windows Forms."

Anchoring and Docking Controls

Two new properties, Anchor and Dock, allow you to position controls on forms in a way that remains consistent even as the forms are resized. The Anchor and Dock properties are discussed in Chapter 12, "Advanced Controls."

Note

There are a number of Visual Basic programming elements that are no longer supported in Visual Basic .NET. The Help topic "Visual Basic 6.0 Programming Elements Not in Visual Basic .NET" contains a very handy alphabetical list of VB6 elements that you may be used to using that have been removed from Visual Basic .NET.



    Team-Fly    
    Top
     



    Special Edition Using Visual Basic. NET
    Special Edition Using Visual Basic.NET
    ISBN: 078972572X
    EAN: 2147483647
    Year: 2001
    Pages: 198

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