我正在分析lotuscript中的一个模块,它正在获取一个NotesDocument。
现在以NotesDocument封装以下数据为例:
docvalue:<html><head> head </head><body>body</body></html>现在,下面的代码是如何工作的?
Dim document As NotesDocument
Dim data as Variant
' Assume code to fetch NotesDocument has been done.
' statement to fetch html data.
data=document.docvalue(0)我没有发现任何Lotus文档可以在":“后取值作为分隔符(在本例中为docvalue:,如上面的数据所示)。请让我知道这是如何工作的或任何文档的链接。
提前谢谢。
发布于 2014-05-30 16:16:33
使用strRight()。它直接从搜索字符串中给出字符串:
data=strRight(document.docvalue(0), ":")发布于 2014-06-02 23:48:53
克努特有正确的答案,如果你使用Notes6.x或更高版本(我相信),你可以使用StrRight()。
另外,我想指出代码应该稍微修改一下。首先将数据声明为变量,然后只读取字段的第一个字符串值。
如果它是一个多值字段(并且您希望在一个数组中返回所有值),则将该变量声明为variant,但读回整个字段。如果您只想要第一个值(或者如果字段只包含一个值),请将data声明为String并像您一样获取第一个元素。
另外,我强烈建议您不要像使用扩展表示法那样使用扩展表示法,而是使用NotesDocument类的GetItemValue方法。它被认为是最佳实践,它是向前兼容的,而且速度更快。同样出于性能方面的原因,我也总是将字段名称完全按照文档中的形式大写。这在这里可能不会有什么不同,但是当您使用例如GetView()时,大小写确实很重要。
因此,您的代码应该如下所示:
Dim doc As NotesDocument
Dim data as String
Dim html as String
' Assume code to fetch NotesDocument has been done.
' statement to fetch html data.
data = doc.GetItemValue("DocValue")(0)
html = StrRight(data,":")
Print html或者,如果您有多个值:
Dim doc As NotesDocument
Dim dataArray as Variant
Dim html as String
' Assume code to fetch NotesDocument has been done.
' statement to fetch html data.
dataArray = doc.GetItemValue("DocValue")
ForAll item in dataArray
html = StrRight(item,":")
Print html
End Forallhttps://stackoverflow.com/questions/23949465
复制相似问题