We help IT Professionals succeed at work.

What is exactly the Me?

jean11
jean11 asked
on
Medium Priority
195 Views
Last Modified: 2013-11-26
Hi

I need help understand the "me" in vb.net as in me.radiobutton1.
 Can you give examples please
What we need it?

Thanks
Jean
Comment
Watch Question

Dirk HaestProject manager
CERTIFIED EXPERT
Commented:
Provides a way to refer to the specific instance of a class or structure in which the code is currently executing

Source: http://msdn.microsoft.com/en-us/library/7e58sbke(VS.80).aspx

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Éric MoreauSenior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016
Commented:
>>me.radiobutton1

The form instance that contains that radio button control.

You don't really need it but Intellisense pops up as soon as you type me.
CERTIFIED EXPERT
Commented:
It's the VB equivilent to the 'this' pointer in C++.

When you define a class or a form, it's possible to have multiple instances of that class or form.  To reference a specific instance from within the class or form, you used 'Me'.

There's not very many instances where 'Me' is needed, but the situation does arise.  

As a trivial example, the following code snippet calls a global function (defined outside of a form or class) to set caption of a form.  



'Global function to set a form's caption based on logic in another function
Public Sub SetMyCaption( F as Form )
  Dim Str as string
  Str = SomeOtherFunctionToDetermineFormCaption( F )
  F.Caption = Str
End Sub
 
'Logic in Form1 to change the Caption
Private Sub UpdateMyCaption
  SetMyCaption( Me )
End Sub

Open in new window

Author

Commented:
Thanks a lot.

but what is instance of a class? if my class is form1 then what is the instant of that?
also I will increase the point if some one answer the following questions please:

what is the difference between:
textbox1.focus(),
textbox1.select, and
textbox1.selectAll()

Éric MoreauSenior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016
Commented:
You can have multiple copies of the Form1 object in memory.

dim f1 as new Form1
dim f2 as new Form1

f1 and f2 are called instances.

The Focus method gives the focus (move the cursor) to that control.

The Select method selects (highlights) a range of characters in the TextBox.

The SelectAll method selects all the characters.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.