其他面向对象的编程语言通常使用 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 )

相关文章:

  • 2022-12-23
  • 2021-07-17
  • 2021-05-29
  • 2022-02-17
  • 2022-02-25
  • 2021-12-29
  • 2021-11-13
  • 2022-12-23
猜你喜欢
  • 2021-06-20
  • 2021-09-07
  • 2021-08-03
  • 2022-12-23
  • 2021-06-12
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案