What Is "Me." in Visual Basic Coding?

  • Thread starter Thread starter SidBord
  • Start date Start date
S

SidBord

In reading some examples written in J. Walkenbach's Visual
Basic Programming book, I noticed he now and then uses the
symbol "Me.". Examples: Me.Activate Me.Saved = True
These were used in discussions of event programs, if that's
any help. I checked, and they aren't defined variables or
arguments.
 
The 'Me' keyword always refers to the instance of the class in
which it is contains. For example, if it appears in the
ThisWorkbook module, it refers to ThisWorkbook. If it appears in
Class1, it refers to the instance of Class1 when the line of code
is executed.

'Me' is only valid in class modules (including userforms,
classes, ThisWorkbook and the Sheet code modules). It is not
valid in a standard module.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
me is used in object modules to refer to the current instance of the
object (or class)

examples of object modules:
userforms => me rfers to the running form
modules for worksheets => me refers to the sheet
thisworkbook => me refers to the workbook in which the code resides

you cannot use it in 'normal modules'





keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 
Me stands for the current control, this way you don't have to retype the
current control's name over and over.

for example if a button control needs to change its own label then you can
just do this:

Me.Label = 'New Name'
 
Thanx, guys. That clears that up.
-----Original Message-----
me is used in object modules to refer to the current instance of the
object (or class)

examples of object modules:
userforms => me rfers to the running form
modules for worksheets => me refers to the sheet
thisworkbook => me refers to the workbook in which the code resides

you cannot use it in 'normal modules'





keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top