CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2000
    Posts
    16

    newbie question (simple)

    What doe the "me" word do? for example when you unload a form you can use unload me

    or when your dealing with a mdb file and using the findfirst command you can use me.data1.recordset

    What does the me signify

    thanks


  2. #2
    Join Date
    Jul 1999
    Location
    USA
    Posts
    101

    Re: newbie question (simple)

    'me' indicates current or active screen

    so 'Unload Me' unloads the active form on display


  3. #3
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: newbie question (simple)

    it actually does a little more than that. When you get into writing class objects, you'll find that using the Me keyword also aliases the current instance of that class. A quick example:

    'this is a class for a user, with properties for first and last name and phone number
    'you have some routine that needs to get this information to perform some action, say save it to a file.
    Function SaveMe() as Boolean
    'open the text here...

    'write my info here...
    objFile.Write me.FirstName & " " & me.LastName & " " & me.PhoneNumber


    'or if you wanted to set these properties...
    me.FirstName = "John"
    me.LastName = "Pirkey"

    'etc...




    The advantage of using the Me keyword here is if you were to have multiple instances of the User class active, you wouldn't be able to tell which one was which by name (eg. clsUser.Firstname - which instance of clsUser - inside the class module's code). The Me operator would then be used inside the class's code to ensure that when the class's properties are set, they are set for the correct instance.

    I hope this didn't confuse you - classes can be very confusing sometimes.

    But in general, the Me keyword is used as another way to talk to the current form. (eg. Me.Hide, Unload Me, etc.)

    Good luck,
    John

    John Pirkey
    MCSD
    www.ShallowWaterSystems.com
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured