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
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值