【发布时间】:2015-03-21 18:32:34
【问题描述】:
我正在尝试将以下函数添加到我的 COM 类库中,但它无法编译。我相信您不能将集合公开给 COM。我认为通过在我的 VS2013 机器和 VB6 机器上使用 RegAsm 并将 Microsoft.VisualBasic.dll 注册为 tlb 可以工作,但不能。
如果不是,那么将某种对象列表传递给 VB6 应用程序的最佳方式是什么。
Public Function GetCustomerCollection() As Collection
Dim collection As New Collection
Dim c1 As New customer
c1.Name = "Test Customer1"
c1.Phone = "(888) 777-9443"
c1.Balance = 22.58
Dim c2 As New customer
c2 .Name = "Test Customer2"
c2 .Phone = "(888) 433-4423"
c2 .Balance = 99.99
collection.Add(c1)
collection.Add(c2)
Return collection
End Function
更新
在 VB6 中,我正在尝试这样来检索列表:
Private Sub Form_Load()
Dim demo As New testLibrary.Demo
Dim customerList As Collection
Set customerList = demo.GetCustomerCollection
Label1.Caption = customerList(1)
End Sub
【问题讨论】:
标签: vb.net com vb6 com-interop