Simple VB.NET Question
What's the difference between using Form1.Text = "My App" and Form1.ActiveForm.Text = "My App" ???
In VB.NET 2002/2003, Form1.Text sets the value of the Form1 variable's Text property to "My App." Form1.ActiveForm.Text sets the value of the application's active form to "My App." ActiveForm is a shared member of the Form class and doesn't really belong to Form1.
In VB 2005, the second example will be invalid. The second will give you a compile error because shared members/properties will no longer be able to be called off of an instance.
In VB 2005, the second example will be invalid. The second will give you a compile error because shared members/properties will no longer be able to be called off of an instance.
RomSteady gave about as good an answer an any... but that will leave you wondering about 1 thing:
What is the use of ActiveForm (shared) member for??
suppose u r designing an MDI (Multiple Document Interface) application and u have multiple child forms... lets say 5 in all.
now u want to set the text of the "active child" form to "My App". instead of iterating through the child forms and finding the active one... u simply write:
MDIMain.ActiveForm.Text="My App"
and your job is done :-)
What is the use of ActiveForm (shared) member for??
suppose u r designing an MDI (Multiple Document Interface) application and u have multiple child forms... lets say 5 in all.
now u want to set the text of the "active child" form to "My App". instead of iterating through the child forms and finding the active one... u simply write:
MDIMain.ActiveForm.Text="My App"
and your job is done :-)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement