Nigel Whitworth's Development Site

You are currently not logged in.

Forms

Microsoft have made subtle changes to the way you handle forms between VB6 and VB.NET. Some of them have been made easier but others as you will guess are more difficult to remember. Its not the complete list, there are others but I'll document them later. For many of the descriptions below, imagine I have an application with one form called Form1


Instatiate Form

Whereas in the previous version, you could simply have a form in the project and activate it. You need to instatiate the form using the NEW keyword then show it.
VB6
    form1.show

VB.NET
    dim frmOne as form1          ' Or merge the top two lines as simply   dim frmOne as new form1
    frmOne = new form1
    formOne.show

Form + Label Caption

In VB6, to change the caption at the top of the form, all you needed to do was say
VB6
    form1.Caption = "New Title"
or
    label1.Caption = "New Label Caption"
The Caption property has now been deleted from the VB vocabulary, you now use Text. Its Microsofts attempt at standardisation and making things clearer.
VB.NET
    form1.text = "New Title"
or
    label1.text = "Nre Label Caption

Changing Backcolor

In previous versions of VB, all you needed to do to set the background colour of a form was to set the backcolor property of a form with a number. Now its slightly more difficult. You get to choose from a list of constants. Setting a form to a colour of your choosing is possible and below is how you would do it.
VB6
    form1.backcolor = &hFF00FF

VB.NET
    form1.backcolor = System.Drawing.Color. < You'll get a list of available colours that can be used.>
    form1.backcolor = System.Drawing.Color.Translator.FromOle(&FF00FF)
    form1.backcolor = System.Drawing.Color.Translator.FromOle(RGB(255,0,255)

Changing Mousepointer

Changing the mousepointer was just a matter of setting the forms mousepointer value, this time its slightly different.
VB6
    me.Mousepointer = vbHourglass

VB.NET
    Cursor.Current = Cursors. < You'll get a list of different mouse pointers available >

Form Events

Microsoft have renamed a few events and below is their old and new names. The parameters have changed slightly. It should also be added, the setfocus property of a control, or a form is now simply FOCUS no need to include the set part of it.

VB6VB.NET
Form_QueryUnloadForm_Closing
Form_UnloadForm_Closed
Form_GotFocusForm_Focus
Form_LostFocusForm_Leave




If you intend to vote or make a comment, please enter the security code. CODE

Make a comment

*Comments are the views of individuals, they may or may not be correct.
All comments are reviewed and accepted or rejected.
If you give an email address, you will be sent an email when someone makes a comment on this page.*

Name :
Email :
Comments :


Only name and Code is compulsory.