Quote:
Dim i As Integer
Dim reply(i) As PingReply
Here you have defined a field with a default value of
0
, and an array of
PingReply
objects with an upper-bound of
0
(and hence a length of
1
).
Quote:
For Me.i = 0 To IPsConnectionStatusDataGridView.RowCount - 1
reply(i) = ...
In this loop, as soon as
i
is greater than
0
, you are trying to store a value beyond the end of your array. This will throw an
IndexOutOfRangeException
.
You need to make sure you array is large enough to store all of the results. Once you know the number of addresses you will be pinging, you need to use
ReDim[
^] to resize the array so that it is large enough.
ReDim reply(IPsConnectionStatusDataGridView.RowCount - 1)
For Me.i = 0 To IPsConnectionStatusDataGridView.RowCount - 1
reply(i) = ...
Alternatively, you could use the
List&(Of T)[
^] class, which wouldn't need to know the number of items up-front.