This seems to be a "thing" with all the VStudio languages. Why do I
refer to things on the form with the Me qualifier, as in
Me.txtWaffle.Text = "Waffles..."
as opposed to the name of the form itself, as in
Form1.txtWaffle.Text = "Waffles..."
?
This is a difficult topic to search for. I'm reading through the new
Lawrenceville Press VB 2005 textbook, and haven't found an answer
yet...
Nick.
In this case Form1 refers to a Type (something that has potential to be)
not an instance of the type. For instance, we can do the following:
dim frmKerry = new Form1
frmKerry.txtWaffle.Text = "Waffles..."
frmKerry.Show()
If you were to allow the syntax you mentioned what would happen if you had
2 instances of the Form1 type as follows:
dim frmRestaurant = new Form1
dim frmKerry = new Form1
Then you made the following statement:
Form1.txtWaffle.Text = "Waffles..." which instance would change the value
in the box? We would want to explicity state that it is the restaurant's
waffles we want to change not the politician's.
The trick is inside of the instance, we need a way to refer to the class
that has been instantiated. "Me" was chosen as the best syntax for VB (C#
uses "this"). As was mentioned previously, "me" applies to the current object.
Since everything in .Net inherits from System.Object, forms, classes, etc
can all use the "Me" syntax and call the localized property.
Jim Wooley
http://devauthority.com/blogs/jwooley/archive/2005/09/21/557.aspx
(In case anyone is interested, I am a liberal and have no problems with politician's
waffling)