Dim iListCount As Long '列表框中记录的行数
Dim varI As Variant
Dim intI As Integer
Dim k As Integer
Dim intSelNo() As String ' 声明动态数组
If Me.ProductList.ColumnHeads Then '判断是否显示了列表框标题,如果是的话总行数需要扣减1
iListCount = Me.ProductList.ListCount - 1
Else
iListCount = Me.ProductList.ListCount
End If
ReDim intSelNo(0 To Me.ProductList.ColumnCount - 1)
If iListCount > 0 Then
For Each varI In Me.ProductList.ItemsSelected 'ItemsSelected为选中行的集合
k = 0
For intI = 0 To Me.ProductList.ColumnCount - 1 '循环列表框中的列
intSelNo(k) = intSelNo(k) & Me.ProductList.Column(k, varI) & ","
k = k + 1
Next intI
'Me.ProductList.Selected(varI) = False '让选中的列不选中
Next
End If
Me.选中的值1 = intSelNo(0)
Me.选中的值11 = intSelNo(1)
Me.选中的值111 = intSelNo(2)