The Redim statement can be overloaded by a class. To use it, implement Operator_Redim in your class.It makes the Redim statement available for objects that were not declared as arrays.


This is not currently supported for Android.

Sample code

Class OneBasedArray
  Sub Constructor(bounds As Integer = 0)
    Redim mArray(bounds - 1)
  End Sub

  Function Count() As Integer
    Return mArray.Ubound + 1
  End Function

  Sub Operator_Redim(newSize As Integer)
    Redim mArray(newSize - 1)
  End Sub

  Function Operator_Subscript(index As Integer) As Variant
    Return mArray(index - 1)
  End Function

  Sub Operator_Subscript(index As Integer, Assigns v As Variant)
    mArray(index - 1) = v
  End Sub

  Private mArray() As Variant
End Class


All project types on all supported operating systems.