What is exactly the Me?

Posted on 2009-02-16
Last Modified: 2013-11-26

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

Question by:jean11
    LVL 53

    Assisted Solution

    Provides a way to refer to the specific instance of a class or structure in which the code is currently executing

    LVL 69

    Assisted Solution

    by:Éric Moreau

    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.
    LVL 16

    Accepted Solution

    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 Comment

    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(),, and

    LVL 69

    Assisted Solution

    by:Éric Moreau
    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.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now