2013-07-16 44 views
0

我有一個按鈕,當您選擇一列時顯示行。但是我有一個問題,因爲它沒有獲得該領域的第二個價值。例如,我選擇列生日,但它有兩個具有相同值的項目(例如1990年1月1日),它只顯示字段中第一個項目的行,而沒有看到第二個項目。你可以幫我嗎?這裏是我的代碼:Lotusscript:沒有得到下一個數組索引

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

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, ".")) 
+0

你真棒人。非常感謝! – drayl

相關問題