迹无痕123 发表于 2021-4-23 10:46

ListView1底部,共有几 条记录代码无效


怎么底部显示多少条记录,无效,在另一个excel中没有问题,但是我更改以后,不统计

Private Sub UserForm_Initialize()
    Dim hwnd As Long
    Dim lStyle As Long
    Dim dic As Object
    hwnd = FindWindow("ThunderDFrame", Me.Caption)    '找到窗口的句柄
    lStyle = GetWindowLong(hwnd, GWL_STYLE)    '获得窗口的样式
    lStyle = lStyle Or WS_MINIMIZEBOX       '在原窗口样式增加最小化按钮
    lStyle = lStyle Or WS_MAXIMIZEBOX       '进一步增加最大化按钮
    lStyle = lStyle Or WS_THICKFRAME      '进一步增加窗口边框,使得窗口可以通过鼠标拖拉改变大小
    SetWindowLong hwnd, GWL_STYLE, lStyle    '将新的窗口样式指定给窗口
    ComboBox1.List = Array("1列", "2列", "3列", "4列", "5列")
    ComboBox1.Value = "4列"
    With Sheet2
      r = .UsedRange.Find(what:="*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
      c = .UsedRange.Find(what:="*", searchorder:=xlByColumns, searchdirection:=xlPrevious).Column
      arr = .Cells(btrow, 1).Resize(r - btrow + 1, c)
    End With
    For j = 1 To UBound(arr, 2)
      Set labelx = Me.Frame9.Controls.Add("Forms.Label.1", "Labelx" & j)
      labelx.Caption = arr(1, j)
      labelx.TextAlign = fmTextAlignCenter
      Set ComboBoxx = Me.Frame9.Controls.Add("Forms.combobox.1", "comboboxx" & j)
      ComboBoxx.Font.Size = 12
      ListView1.ColumnHeaders.Add , , arr(1, j)
      If j > 1 Then
            ListView1.ColumnHeaders(j).Alignment = lvwColumnCenter
      End If
    Next j
    ListView1.View = lvwReport      'listivew的显示格式为报表格式
    ListView1.Sorted = False          'listivew的排序属性为false
    ListView1.Gridlines = True      '显示网格线
    ListView1.FullRowSelect = True    '允许整行选中
    For i = 2 To UBound(arr)          '设置循环,填充记录
      Set Itm = ListView1.ListItems.Add(, "行号" & i + btrow - 1, arr(i, 1))
      For j = 2 To UBound(arr, 2)
            Itm.SubItems(j - 1) = arr(i, j)
      Next j
    Next i
    Label2.Caption = "共有 " & ListView1.ListItems.Count & " 条记录"
    Me.Controls("comboboxx1").SetFocus
    Call UserForm_Resize
    Call sumcol
    Call gengxinlist
End Sub


页: [1]
查看完整版本: ListView1底部,共有几 条记录代码无效