'With...End With' block:
- Internally, a reference to the variable is taken at the start of the 'With' block, and then is used to calculate any element accesses within the block.
- But, normally, creating a reference (by 'Dim Byref...') to a temporary variable is forbidden.
Examples:
- With a local instance:
Code: Select all
Type UDT
Dim As Integer I
Dim As Integer J
End Type
Dim As UDT u = Type<UDT>(1, 2)
With u
Print .I
Print .J
End With
Code: Select all
Type UDT
Dim As Integer I
Dim As Integer J
End Type
Dim As UDT u = Type<UDT>(1, 2)
Scope
Dim Byref As UDT ref = u
Print ref.I
Print ref.J
End Scope
- With a temporary instance:
Code: Select all
Type UDT
Dim As Integer I
Dim As Integer J
Declare Constructor(Byval i0 As Integer, Byval j0 As Integer)
End Type
Constructor UDT(Byval i0 As Integer, Byval j0 As Integer)
This.I = i0
This.J = j0
End Constructor
With UDT(1, 2)
Print .I
Print .J
End With
Code: Select all
Type UDT
Dim As Integer I
Dim As Integer J
Declare Constructor(Byval i0 As Integer, Byval j0 As Integer)
End Type
Constructor UDT(Byval i0 As Integer, Byval j0 As Integer)
This.I = i0
This.J = j0
End Constructor
Scope
Dim Byref As UDT ref = UDT(1, 2) '' error 24: Invalid data types
Print ref.I
Print ref.J
End Scope
Is this 'With...End With' functionality desired for a temporary instance and will therefore be maintained in future versions ?