Notes中几个处理多值域的通用函数

简介:

1.查找出查找内容在多值域中的索引值
getItemIndex(域名,域值,文档)

Public Function getItemIndex(ByVal fieldName As String, ByVal itemVal As Object, 
ByVal doctt As NotesDocument) As Integer Dim i As Integer Dim j As Integer Dim item As NotesItem item = doctt.GetFirstItem(fieldName) j = Ubound(item.Values) For i = 0 To j If itemVal = item.Values(i) Then getItemIndex = i Exit Function End If Next getItemIndex = -1 End Function

2.删除多值域中的数据
delItemValues(多值域名,更改的索引值,所在文档对象)

Public Sub delItemValues(ByVal fieldName As String, ByVal index As Integer, ByVal doctt As NotesDocument)
    Dim i As Integer
    Dim temp() As Object
    Dim item As NotesItem
    item = doctt.GetFirstItem(fieldName)
    Dim j As Integer

    j = Ubound(item.values)
    '-----------
    If j = 0 Then
        '当J为0时,即仅有一个值,给予空值即可
        Call doctt.ReplaceItemValue(fieldName, "")
        Exit Sub
    End If
    '------------
    If Trim(item.Values(0)) = "" Then
        index = j
    End If
    If index > j Then
        '仍然做为最后一个数据加入  
        j = j + 1  '索引位仅增加1
        index = j  '重定义索引位,防止超出范围
    End If

 Redim temp(j-1) As Variant '重定义数组 
    For i = 0 To index - 1
        temp(i) = item.values(i)
    Next

    For i = index To j - 1
        temp(i) = item.values(i + 1)
    Next

    Call doctt.ReplaceItemValue(fieldName, temp)
    'End If
    'End If
End Sub

3.更改多值域中的数据
editItemValues(多值域名,更改的索引值,更改的内容,所在文档对象)

Public Sub editItemValues(ByVal fieldName As String, ByVal index As Integer, ByVal itemVal As Object, 
ByVal doctt As NotesDocument) Dim i As Integer Dim temp() As Object Dim item As NotesItem item = doctt.GetFirstItem(fieldName) Dim j As Integer j = Ubound(item.values) If Trim(item.Values(0)) = "" Then index = j End If If index > j Then '仍然做为最后一个数据加入 j = j + 1 '索引位仅增加1 index = j '重定义索引位,防止超出范围 End If Redim temp(j) As Variant '重定义数组 For i = 0 To j If i = index Then temp(i) = itemVal Else temp(i) = item.values(i) End If Next Call doctt.ReplaceItemValue(fieldName, temp) 'End If 'End If End Sub


本文转自生鱼片博客园博客,原文链接:http://www.cnblogs.com/carysun/archive/2008/12/29/Notes-Multi-Field.html,如需转载请自行联系原作者
相关文章
|
14天前
|
SQL API Python
Python DB API下规范下cursor对象常用接口
Python DB API下规范下cursor对象常用接口。
16 4
|
6月前
|
数据库
ABAP MESSAGE 关键字的使用方法
ABAP MESSAGE 关键字的使用方法
41 0
|
XML 存储 JSON
API参考—参数管理—ModifyParameter
调用ModifyParameter接口修改参数值。
|
机器人
Robot Framework(6)- BuiltIn 测试库常用的关键字列表
Robot Framework(6)- BuiltIn 测试库常用的关键字列表
218 0
Robot Framework(6)- BuiltIn 测试库常用的关键字列表
|
机器人
Robot Framework(7)- DateTime 测试库常用的关键字列表
Robot Framework(7)- DateTime 测试库常用的关键字列表
487 0
Robot Framework(7)- DateTime 测试库常用的关键字列表
|
Web App开发 API 开发者
如何在调用Marketing Cloud contact创建API时增加对扩展字段的支持
如何在调用Marketing Cloud contact创建API时增加对扩展字段的支持
如何在调用Marketing Cloud contact创建API时增加对扩展字段的支持
|
Go
go接口及嵌入类型例子
书上看的。慢慢领会。。 package main import ( "fmt" ) type notifier interface { notify() } type user struct { name string email string } func (u *user) notify() { fmt.
934 0
|
前端开发 API 容器
select2 api参数的文档
select2 api参数的文档  官网文档地址是:http://select2.github.io/select2/#documentation。 具体参数可以参考一下: 参数   类型   描述 Width 字符串 控制 宽度 样式属性的Select...
1270 0