Table of contents
TOC
折叠目录
展开目录

Me

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

Me关键字的行为类似的隐式声明变量。它可自动用于到类模块中的每个过程。当一个可以有多个实例时, Me提供了一种方法来引用代码正在运行的类的特定实例。使用Me是特别有用的到另一个模块中的过程传递关于某个类的当前执行实例的信息。例如,假设您的模块中有下面的过程:The Mekeyword behaves like an implicitly declaredvariable. It is automatically available to every procedure in aclass module. When a class can have more than one instance, Me provides a way to refer to the specific instance of the class where the code is executing. Using Me is particularly useful for passing information about the currently executing instance of a class to a procedure in anothermodule. For example, suppose you have the following procedure in a module:

Sub ChangeFormColor(FormName As Form) 
 FormName.BackColor = RGB(Rnd * 256, Rnd * 256, Rnd * 256) 
End Sub

您可以调用此过程,并传递窗体的类的当前实例作为参数使用以下语句You can call this procedure and pass the current instance of the Form class as an argument using the followingstatement:

ChangeFormColor Me 
© 2018 Microsoft