我发现这段代码可以遍历并打印出两列的 csv。我稍后解析并计算这两列。我想在这里数一下,而不是打印出来然后再数。我一直在摸索,但无法弄清楚。
Dim entry As NotesViewEntry
Dim vc As NotesViewEntryCollection
Dim rowstring As String
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim view As NotesView
Set view = db.GetView( nameofview )
Set vc = view.AllEntries
Set entry = vc.GetFirstEntry()
While Not entry Is Nothing
rowstring = ""
Forall colval In entry.ColumnValues
If rowstring = "" Then
rowstring = colval
Else
rowstring = rowstring + +"," + colval
End If
End Forall
Wend
感谢您提前提供的任何帮助。
最佳答案
试试这个,它通过将 colval 字符串转换为数值来将列累积到 rowval 中。如果 double/CDbl() 是浮点型,您也可以轻松使用它们。这是假设,通过“计算两列”,您的意思是将它们相加并输出总和。如果您的意思是字面意思计数,则将其保留为 Integer
并更改行
rowval = rowval + CInt(colval)
至
rowval = rowval + 1
这里是:
Dim entry As NotesViewEntry
Dim vc As NotesViewEntryCollection
Dim rowval As Integer ' or Double '
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim view As NotesView
Set view = db.GetView( nameofview )
Set vc = view.AllEntries
Set entry = vc.GetFirstEntry()
While Not entry Is Nothing
rowval = 0
Forall colval In entry.ColumnValues
rowval = rowval + CInt(colval) ' Or CDbl() '
End Forall
' Output rowval here. '
Set entry=vc.GetNextEntry (entry)
Wend
根据您的原始示例,我没有输出任何内容(?),但我已在您应该执行的位置添加了注释。
关于lotus-notes - 我需要 View 中两列的总和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/555277/