confusion123
Active Member
- Joined
- Jul 27, 2014
- Messages
- 400
This article states objects are always passed ByRef,passing arrays are always ByRef and passing classes are like passing object variable types.
Passing Variable ByRef And ByVal
This is my code in a class:
The code works perfectly but I am confused. Am I passing a class or an array or both?
Note the keywords ByVal.
If I am passing a class (or an array) then according to the article, it should be passed ByRef only.
Passing Variable ByRef And ByVal
This is my code in a class:
Code:
Private pDataArray As Variant
Private pDataArrayRows As Integer
Property Get DataArray() As Variant
DataArray = pDataArray
End Property
Property Let DataArray(ByVal DArray As Variant)
pDataArray = DArray
End Property
Property Get DataArrayItem(ByVal RowIndex As Integer, _
ByVal ColIndex As Integer) As Variant
DataArrayItem = pDataArray(RowIndex, ColIndex)
End Property
Property Let DataArrayItem(ByVal RowIndex As Integer, _
ByVal ColIndex As Integer, _
ByVal Item As Variant)
pDataArray(RowIndex, ColIndex) = Item
End Property
Public Sub EraseArray()
If IsArray(pDataArray) Then Erase pDataArray
End Sub
Property Get DataArrayRows() As Integer
DataArrayRows = pDataArrayRows
End Property
Property Let DataArrayRows(ByVal DArrayRows As Integer)
pDataArrayRows = DArrayRows
End Property
The code works perfectly but I am confused. Am I passing a class or an array or both?
Note the keywords ByVal.
If I am passing a class (or an array) then according to the article, it should be passed ByRef only.
Last edited: