2

我发现这段代码通过并打印出两列的 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

感谢您提前提供任何帮助。

4

1 回答 1

3

试试这个,它通过将 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

根据您的原始示例,我没有输出任何内容(?),但我已经在您应该做的地方发表了评论。

于 2009-02-17T02:07:23.893 回答