Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
This 'ME' thing
Message
From
08/01/2013 11:09:58
 
 
To
08/01/2013 10:30:38
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01561723
Message ID:
01561731
Views:
60
>>>Ok...this whole 'ME' thing that VB has going on is very confusing.
>>>
>>>I'm working in a TextBox_TextChanged event handler
>>>
>>>I get the whole 'ME' here refers to the TextBox, so, one would think, if I wanted to change the text of a label (lblStudentName) I would refer to it as me.parent.lbl, but it doesn't seem to like that. It wants me.lblStudentName.Text. It seems to kinda act like the royal 'we'.
>>>
>>>
>>>This is very confusing and is there a better way to refer to other controls on the form other than Form.lbl...?
>>
>>Me refers to the current class. Your eventhandler is probably written as a method of the form so me = the form.
>
>Definately an "I'm my uncle's brother" kinda thing

Perfectly logical. It your form looks like this:
Public Class Form1

Private Sub TextBox1_TextChanged( sender As Object,  e As EventArgs) Handles TextBox1.TextChanged
   Dim tb As TextBox = Me.TextBox1
End Sub
End Class
then TextBox1_TextChanged() is a member of Form1 so that is what Me refers to. If it makes you happier you could use 'Dim tb As TextBox = sender' :-}
Previous
Reply
Map
View

Click here to load this message in the networking platform