我想要一个互操作用户控件(VB.NET)返回并接受来自 get/set 调用的多个值。我假设用户定义类型 (UDT) 是正确的方法,但我不断从 VB6 编译中得到“变量使用 Visual Basic 不支持的自动化类型”。如何在互操作控件和 VB6 应用程序之间传递多个值?
VB.NET (Interop) 代码,一个带有 .NET ListView 的控件
Structure Employee
Dim Firstname As String
Dim Lastname As String
End Structure
…</p>
Public Property MyReadListViewData() As Employee
Get
Dim myEmployee As Employee
myEmployee.Lastname = ListView1.SelectedItems(0).Text
Return myEmployee
End Get
Set(ByVal value As Employee)
Me.ListView1.SelectedItems(0).Text = value.Lastname
End Set
End Property
典型的 VB6 代码:
Private Sub Command4_Click()
Dim myEmployee As Employee
myEmployee = MyToolStrip1.MyReadListViewData
Text3.Text = myEmployee.Lastname
End Sub