昨天从我的问题中转发。 完整的代码如下: 我认为问题出在.Column = MyArray,在那里我通过.column而不是.additem将值发送到列表框。但是我不知道如何添加数组。
Option Explicit
Dim MyArray As Variant
Dim n As Integer
Private Sub UserForm_initialize()
n = 0
End Sub
Private Sub FBcv_aDD_Click()
ReDim MyArray(4, n)
Dim i As Long
'============================================
If ListBox_FB.ListIndex = True Then
MyArray(0, n) = "Cavity Fixing Block"
MyArray(1, n) = FBcv_L.Value & " x " & FBcv_W.Value & " x " & FBcv_T.Value
If FBcv_Qty <= 1 Then
MyArray(2, n) = FBcv_Qty.Value & "pc."
ElseIf FBcv_Qty > 1 Then
MyArray(2, n) = FBcv_Qty.Value & "pcs."
End If
MyArray(3, n) = FBmat.Value
MyArray(4, n) = FBcv_uPRICE.Value
n = n + 1
End If
'============================================
With ListBox_FB
For i = 0 To ListBox_FB.ListCount - 1
If ListBox_FB.ListIndex = False Then
.AddItem ListBox_FB.List(i, 0)
ListBox_FB.List(ListBox_FB.ListCount - 1, 1) = ListBox_FB.List(i, 1)
ListBox_FB.List(ListBox_FB.ListCount - 1, 2) = ListBox_FB.List(i, 2)
ListBox_FB.List(ListBox_FB.ListCount - 1, 3) = ListBox_FB.List(i, 3)
ListBox_FB.List(ListBox_FB.ListCount - 1, 4) = ListBox_FB.List(i, 4)
End If
Next i
.ColumnCount = 5
.TextAlign = 1
.Column = MyArray
End With
End Sub
对不起,我不得不重新发布它,我搞砸了我的第一个问题。
有人可以帮我解决这个问题吗? 非常感谢您的帮助。谢谢advanCce。