zoukankan      html  css  js  c++  java
  • Notes中几个处理多值域的通用函数

    转自:http://www.hanhe-tech.com:8089/blog/318-5102.html

    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/luoaz/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利

  • 相关阅读:
    Redis面试总结
    文件上传文件的权限lnmp 环境配置,尤其整个项目复制过来
    linux cat /etc/passwd 说明
    php上传文件与图片到七牛的实例详解
    一起谈.NET技术,参数编码 完全解决方案 狼人:
    一起谈.NET技术,在.NET中使用域对象持续模式 狼人:
    一起谈.NET技术,从.NET中委托写法的演变谈开去(中):Lambda表达式及其优势 狼人:
    一起谈.NET技术,从扩展方法到流畅的程序体验(一) 狼人:
    一起谈.NET技术,构建高性能ASP.NET站点之一 剖析页面的处理过程(前端) 狼人:
    一起谈.NET技术,ASP.NET MVC 2 验证消息本地化策略扩展 狼人:
  • 原文地址:https://www.cnblogs.com/luoaz/p/2308024.html
Copyright © 2011-2022 走看看