0

从我昨天的问题中重新发布。下面的完整代码:我认为问题出在 .Column = MyArray 上,我通过 .column 而不是 .additem 将值发送到 Listbox。但我不知道如何 .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

对不起,我不得不重新发布这个,我搞砸了我的第一个问题。

谁能帮我解决这个问题?非常感谢任何帮助。提前感谢。

4

0 回答 0