An array cannot have a negative index. So as far as I can see you have three options:
- modify the code to use 0 based arrays
- use 0 based indexing but when using the index subtract/add 2, depending on the situation.
- use a
Dictionary(Of TKey, TValue) Class[
^]
Some examples
Dim N1 As Integer = 100
Dim W1(0) As Integer
ReDim W1(0 To N1 + 4)
For counter As Integer = 0 To 104
W1(counter) = counter
Next
Dim N2 As Integer = 100
Dim W2(0) As Integer
ReDim W2(0 To N2 + 4)
For counter As Integer = -2 To 102
W2(counter + 2) = counter
Next
Dim W3 As System.Collections.Generic.Dictionary(Of Integer, Integer)
W3 = New Dictionary(Of Integer, Integer)
For counter As Integer = -2 To 102
W3.Add(counter, counter)
Next