本文介绍了从OCX返回多维数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建一个ocx,它具有调用返回数组的函数的属性。它适用于一维数组,但不适用于多维数组。我从使用ocx获取多维数组的应用程序中得到'下标超出范围'错误。
这是函数:
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:
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
这是ocx中的Get属性:
Here is the Get property in the ocx:
Property Get ItemList() As String()
Dim iList() As String
iList = GetItemsList()
End Property
在使用ocx的应用程序中我有:
In the application which uses the ocx I have:
Dim iList() As String
iList = Warehouse1.ItemList
here is where I get the error:
For i = LBound(iList) To UBound(iList)
如果我将函数直接放入应用程序而不是调用它,同样的过程工作正常通过ocx。我做错了什么?
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?
推荐答案
这篇关于从OCX返回多维数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!