Public Class VBArray(Of T)
Private _lbound As Integer
Private _myitems() As T
Public Sub New(ByVal LBound As Integer, ByVal UBound As Integer)
Me.ReDim(LBound, UBound)
End Sub
Public Sub [ReDim](ByVal LBound As Integer, ByVal UBound As Integer)
_lbound = LBound
ReDim _myitems(UBound - LBound + 1)
End Sub
Default Public Property Item(ByVal Index As Integer) As T
Get
Return _myitems(Index - _lbound)
End Get
Set(ByVal Value As T)
_myitems(Index - _lbound) = Value
End Set
End Property
Public Function ToArray() As T()
Return _myitems
End Function
End Class
Sub Main()
Dim socketBins4 = Array.CreateInstance(GetType(Byte), New Integer() {DUT, SOCK, 1000}, New Integer() {1, 1, 1})
Dim arrayLenghts() As Integer = {DUT, SOCK, 1000}
Dim arrayLowerBounds() As Integer = {1, 1, 1}
Dim socketBins3 = Array.CreateInstance(GetType(Byte), arrayLenghts, arrayLowerBounds)
socketBins3(1, 1, 1) = 10
MsgBox("LBound for FirstDimension = " & LBound(socketBins3, 1))
MsgBox("LBound for SecondDimension = " & LBound(socketBins3, 2))
MsgBox("LBound for ThirdDimension = " & LBound(socketBins3, 3))
MsgBox("UBound for FirstDimension = " & UBound(socketBins3, 1))
MsgBox("UBound for SecondDimension = " & UBound(socketBins3, 2))
MsgBox("UBound for ThirdDimension = " & UBound(socketBins3, 3))
socketBins3(0, 0, 0) = 10 ' <--- This will throw an exception
'This are other possibilities
'This is not possible Dim socketbins(1 to DUT, 1 to SOCK, 1 to 1000) as Byte
Dim socketbins(0 To DUT, 0 To SOCK, 0 To 1000) As Byte
Dim socketBins2 As New VBArray(Of VBArray(Of VBArray(Of Byte)))(1, DUT)
'And then some init code here
End Sub
End Module