Click to See Complete Forum and Search --> : newbie question (simple)


ross
February 17th, 2000, 03:47 PM
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

sriky
February 17th, 2000, 04:09 PM
'me' indicates current or active screen

so 'Unload Me' unloads the active form on display

Johnny101
February 17th, 2000, 05:04 PM
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