May 1995
Beginner
508 pages
16h 14m
English
Me Operator
Me
The Me operator can represent a class, but only
from within that class.
Me is an implicit reference to the current object
as defined by the Class...End Class statement.
In this example, a class method in a WSH script passes an instance of
itself to a function outside of the class by using the
Me operator:
Dim oCtr Set oCtr = New CCounter oCtr.Increment oCtr.Increment MsgBox "Count: " & oCtr.ShowCount ' definition of CCounter class Class CCounter Private lCtr Property Get Value Value = lCtr End Property Private Sub Class_Initialize( ) lCtr = 1 End Sub Public Sub Increment( ) lCtr = lCtr + 1 End Sub Public Function ShowCount( ) ShowCount = ShowObjectValue(Me) End Function End Class ' Show value of an object's Value property Public Function ShowObjectValue(oObj) ShowObjectValue = oObj.Value End Function
The Me operator can’t be used on the left
side of an expression.
The Me operator is particularly useful when
passing an instance of the current class as a parameter.
| Class Statement |
Read now
Unlock full access