求高手帮忙逐行注释一下VB这一段的代码, 小弟急需要用,谢谢各位了 十分感谢啊。急求!!!
PrivateSubShowPage(rsAsRecordset,nPageAsInteger)rs.AbsolutePage=nPagelv.ListItems.Cle...
Private Sub ShowPage(rs As Recordset, nPage As Integer)
rs.AbsolutePage = nPage
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 展开
rs.AbsolutePage = nPage
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 展开
1个回答
展开全部
逐行没必要了,帮你注释下主要的
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
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
追问
For k = 1 To lv.ListItems.Count - 1
item.SubItems(2) = CInt(lv.ListItems(k).SubItems(2)) + CInt(item.SubItems(2))
您好,这句还是不太明白 能帮忙再解释一下么 谢谢了
追答
item的子项SubItems(2)等于 lv的项ListItems(k)的子项SubItems(2) 取整
加上 item.SubItems(2)取整
其中 For k = 1 To lv.ListItems.Count - 1 表示循环,循环次数K从1开始到lv.ListItems的总项目数-1
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询