Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I'm making an ocx which has properties that call functions which return arrays. It works fine for one dimensional arrays, but not for multidimensional arrays. I get a 'subscript out of range' error from the application which is using the ocx to get multidimensional arrays.

Here is the function:
VB
Public Function GetItemsList() As String()

Dim wI As Integer 'Number of Items

Dim x As Integer
Open "WarehouseInventory.dat" For Random As #1 Len = 126
wI = LOF(1) / 126

ReDim Items(1 To wI, 3) As String
  For x = 1 To wI
     Get #1, x, wItem
     Items(x, 1) = wItem.Description
     Items(x, 2) = wItem.FluidicPart
     Items(x, 3) = wItem.ManufPart
  Next x
Close
GetItemsList = Items

End Function



Here is the Get property in the ocx:
VB
Property Get ItemList() As String()

Dim iList() As String
iList = GetItemsList()

End Property


In the application which uses the ocx I have:
VB
Dim iList() As String
iList = Warehouse1.ItemList

here is where I get the error:
For i = LBound(iList) To UBound(iList)


The same process works fine if I put the function directly into the application instead of calling it through the ocx. What am I doing wrong?
Posted

1 solution

Hola amigo,
The LBound function and The Ubound function can just get the first dimensional of
a multidimensional array.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900