lotus-notes - 我需要 View 中两列的总和

标签 lotus-notes lotus-domino lotusscript

我发现这段代码可以遍历并打印出两列的 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/

相关文章:

xpages - 如何在Xpages事件中实现“continue = false”

java - 莲花多米诺 9 : Unable to register user without creating ID file using Java client API

java - ViewEntry - columnValues.get(0) 有时是多值列

javascript - Notes 7.0.3 客户端在没有太多 JavaScript 的表单上编译 JavaScript 时抛出错误。关于潜在原因的任何想法?

javascript - 将响应显示为 XPages 父文档上的嵌入 View

java - 无法从 Java 代理访问文件系统

java - 如何从 Lotus Notes 启动应用程序,然后保存到 Lotus 数据库?

java - 相同的代码,通过 Lotus Domino 发送电子邮件的不同行为

lotus-domino - NotesJsonNavigator 和国际字符

lotus-notes - Lotus Notes/LotusScript - 如何用德语而不是英语设置日期?