其他面向对象的编程语言通常使用 this 或者 self 关键字来访问当前对象,而 VBS 使用的是 Me 关键字。Me 关键字代表着类在代码运行时的当前实例(instance),或者说,当前对象(object)。
Class myClass Private i_count Public Property Get count i_count = i_count + 1 count = i_count End Property ' 递增 Public Sub countTwice i_count = Me.count + Me.count End Sub Public Property Let count(c) i_count = c End Property End Class set X = new myClass X.count = 20 x.countTwice() MsgBox( X.count )