逐行没必要了,帮你注释下主要的
Private Sub ShowPage(rs As Recordset, nPage As Integer)
rs.AbsolutePage = nPage '指定当前记录所在的页,这里最好做rs.recorecound>0判断防止出错
lv.ListItems.Clear ’索引清空
Dim item As ListItem
For i = 1 To 40 ’循环
If rs.EOF = True Then '如果到记录集尾
Set item = lv.ListItems.Add(, , "合计") ‘加入一行字符串
item.SubItems(2) = 0 '特定子序号赋值
For k = 1 To lv.ListItems.Count - 1
item.SubItems(2) = CInt(lv.ListItems(k).SubItems(2)) + CInt(item.SubItems(2))
Next
Exit Sub ‘退出该过程
End If
Set item = lv.ListItems.Add(, , Trim(rs.Fields(0).Value))
For j = 1 To rs.Fields.Count - 1
item.SubItems(j) = IIf(IsNull(rs.Fields(j)), "", Trim(rs.Fields(j)))
Next
rs.MoveNext ’记录集移动到下一个记录
Next
End Sub