ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What Is "Me." in Visual Basic Coding? (https://www.excelbanter.com/excel-programming/303707-what-me-visual-basic-coding.html)

SidBord

What Is "Me." in Visual Basic Coding?
 
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.

Chip Pearson

What Is "Me." in Visual Basic Coding?
 
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



"SidBord" wrote in message
...
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.




keepITcool

What Is "Me." in Visual Basic Coding?
 
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


"SidBord" wrote:

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.



Township of East Hanover

What Is "Me." in Visual Basic Coding?
 
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'

"SidBord" wrote in message
...
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.




SidBord

What Is "Me." in Visual Basic Coding?
 
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


"SidBord" wrote:

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.


.



All times are GMT +1. The time now is 02:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com