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
对于LotusScript,除了Rich-Text域外的元素,如文本、单选框、列表框、复选框等,你可以用几乎相同的代码取得它们的值。例如:如果有一个“Location”域,不论它是何种类型,你都可以用下面的LotusScript代码取得它的值:   fieldVals = doc.Location   或者这样:   fieldVals = doc.GetItemValue("Location")   在LotusScript中,域的类型对于你要取值(值数组)的代码并不重要。但是在JavaScript中,不同类型的域除了显示选项(比如单选框、复选框或者文本)外,并不像在Notes里那样,它们是不同的类型的对象,每一个都要用不同的方式去引用。其实,那也不是绝对的,有些对象是相似的,但是引用过程并不像在LotusScript里那么流畅。   在JavaScript中,没有所谓的Rich-Text域,在HTML中更没有。Notes里提供了一个可以放在浏览器里的富文本Java(不是JavaScript)小程序,从而可以得到富文本的一些功能,但是你并不能用JavaScript来对它编程,而且它也不是一个真正的HTML对象类型。   更让Notes开发人员惊讶的是,在Web上还没有数字型或时间型的域。HTML的域都是文本型的。尽管你能用它们来收集数字信息,如数量或单价,而保存的数据依然是文本。为了像数字一样使用它,你必须把它转换成数字类型。另一个区别是在Web上没有计算域,但并不意味着你不能在你的表单里加入计算域。你可以加入计算域,计算值将会在Web页中显示,除非域是隐藏的。关键是即使域就在那里显示,而HTML通常的处理是没有定义域。如果你把test域改成计算域而不是可编辑的,在测试时你会发现其值是取不到的,我们可以对比下计算域和可编辑域生成的html代码:   计算域的时候生成的代码(js是取不到值的):      action="/weboa/ggxx/Dinner.nsf/test?OpenForm&Seq=1" name="_test">
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值