Simple VB.NET Question

Started by
2 comments, last by Kryptus 18 years, 11 months ago
What's the difference between using Form1.Text = "My App" and Form1.ActiveForm.Text = "My App" ???
Advertisement
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.
Michael Russell / QA Manager, Ritual EntertainmentI used to play SimCity on a 1:1 scale.
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 :-)
Cool. That answered my question perfectly. Thanks guys.

This topic is closed to new replies.

Advertisement