tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,759
- Office Version
-
- 365
- 2019
- Platform
-
- Windows
The error handling here does not seem to handle it.
Put some data in say the first three rows from A1 to D3 for example.
Clearly the array will have only 9 elements and in particular will crash on this line:
Question is why does the error handler not deal with it?
Class1:
Module1;
Put some data in say the first three rows from A1 to D3 for example.
Clearly the array will have only 9 elements and in particular will crash on this line:
Code:
EntryArray.DataArrayItem(10, 1)
Question is why does the error handler not deal with it?
Class1:
Code:
Option ExplicitPrivate pDataArray As Variant
Property Let DataArray(DArray As Variant)
pDataArray = DArray
End Property
Property Get DataArrayItem(RowIndex As Integer, _
ColIndex As Integer) As Variant
DataArrayItem = pDataArray(RowIndex, ColIndex)
End Property
Module1;
Code:
Option Explicit
Sub Test()
On Error GoTo ErrHandler
Dim EntryArray As Class1
Set EntryArray = New Class1
Dim a As Variant
EntryArray.DataArray = Cells(1, 1).CurrentRegion.Value
a = EntryArray.DataArrayItem(10, 1)
ErrHandler:
Exit Sub
End Sub