Lotusscript:没有得到下一个数组索引

时间:2013-07-16 10:55:36

标签: lotusscript

我有一个按钮,当您选择一列时会显示该行。但我有一个问题'因为它没有获得该领域的第二个价值。例如,我选择列生日,但它有两个具有相同值的项目(例如1990年1月1日),它只显示字段中第一个项目的行,而不是第二个项目。你能帮助我吗?这是我的代码:

Sub Getvalue
Dim uidoc As NotesUIDocument
Dim ws As New NotesUIWorkspace
Dim printcolumn As String
Dim columnList() As String
Dim y As Integer

'-- print column --
For a =  0 To 10    
    setfield = "Untitled" &  x
    Set uidoc = ws.CurrentDocument
    printfield = uidoc.FieldGetText(setfield)

    Redim Preserve columnList(11)
    columnList(a) = printfield      
    x = x + 10      
Next    

printcolumn = ws.Prompt(4,"Column List", "Select:", , columnList)       

indexresult = (Arraygetindex(columnList, printcolumn)) + 1

'-- print row --
y = (indexresult*10) + 1

For b =  0 To 9
    setrowfield = "Untitled" &  y
    Set uidoc = ws.CurrentDocument
    printrowfield = uidoc.FieldGetText(setrowfield)

    Redim Preserve rowList(10)
    rowList(b) = printrowfield
    y = y + 1       

Next    
printrow = ws.Prompt (4,"Row List", "", ,rowList)   

'-- for duplicates --
Forall prow In columnList
    If printcolumn = prow Then
        indexresult2 = (Arraygetindex(columnList, prow)) + 1
        z = (indexresult2*10) + 1

        For b =  0 To 9
            setrowfield = "Untitled" &  z
            Set uidoc = ws.CurrentDocument
            printrowfield = uidoc.FieldGetText(setrowfield)

            'Redim Preserve rowList(10)
            rowList(b) = printrowfield
            z = z + 1       
            'printrow = ws.Prompt(4,"Row List", "", ,rowList)                       
        Next    
        printrow = ws.Prompt(4,"Row List", "", ,rowList)    
    End If

End Forall  

End Sub

1 个答案:

答案 0 :(得分:1)

columnList必须拥有Prompt的唯一成员。实现此目的的最简单方法是在每行前面添加行号。作为一个好处,您可以非常轻松地选择indexresult的行号。

您的列表如下所示:

1. January 1, 1990
2. January 1, 1990
3. January 1, 1990
...

这是改编的代码:

Set uidoc = ws.CurrentDocument
Redim Preserve columnList(11)
For a =  0 To 10    
    setfield = "Untitled" &  x
    printfield = uidoc.FieldGetText(setfield)
    columnList(a) = (a+1) & ". " & printfield 
    x = x + 10           
Next    

printcolumn = ws.Prompt(4,"Column List", "Select:", , columnList)       
indexresult = cint(strLeft(printcolumn, "."))