Hidden instance parameter passed to non-static member functions in a Type or Class

With this
End With

This is a reference to an instance of a Type or Class that is passed (through a hidden Byref parameter) to all non-static member functions of that type or class. Non-static member functions are procedures declared inside the body of a Type or Class and include Sub, Function, Constructor, Destructor, assignment or Cast Operator, and Property procedures.

The This additional parameter has the same data type as the Type or Class in which the procedure is declared.

The This parameter can be used just like any other variable, ie., pass it to procedures taking an object of the same type, call other member procedures and access member data using Operator . (Member access), etc.

Most of the time, using This explicitly for member access is unnecessary; member procedures can refer to other members of the instance which they are passed directly by name, without having to qualify it with This and Operator . (Member access). The only times when you need to qualify member names with This is when the member is shadowed, for example by duplicating its name for a local variable or parameter. In these situations, qualifying the member name is the only way to refer to these masked member names.

Type sometype
    Declare Sub MyCall()
    value As Integer
End Type

Dim example As sometype

'' Set element test to 0
example.value = 0
Print example.value


'' Output should now be 10
Print example.value

End 0

Sub sometype.MyCall()
    This.value = 10
End Sub

Differences from QB:
See also:
Back to User Defined Types
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki phatcode