1

我在 Do While 循环结束时收到“未设置对象变量”。当我调试代理时,满足条件后指针指向“循环”。条件是,如果文档等于 10 个文档(小于 11 个),则必须继续。你能帮助我吗?下面是代码:

Const NotesMacro$ = {@DBColumn("":"";@dbname;"Top10DCV";2)}
    retval = Evaluate(NotesMacro$)
    For t = 0 To UBound(retval)
        Set vc = CSVview.GetAllEntriesByKey(retval(t), True)
        Set v2entry = vc.GetFirstEntry
        doccount1 = 0

    Do While doccount1 < 11 AND v2entry.isValid()

            ReDim Preserve tmpArray3(tmpcount3)
            ReDim Preserve tmpArray4(tmpcount4)
            ReDim Preserve tmpArray5(tmpcount5)
            ReDim Preserve tmpArray6(tmpcount6)
            ReDim Preserve tmpArray7(tmpcount7)
            ReDim Preserve tmpArray8(tmpcount8)
            ReDim Preserve tmpArray9(tmpcount9)
            ReDim Preserve tmpArray10(tmpcount10)
            ReDim Preserve tmpArray11(tmpcount11)
            ReDim Preserve tmpArray12(tmpcount12)
            ReDim Preserve tmpArray13(tmpcount13)
            ReDim Preserve tmpArray14(tmpcount14)
            ReDim Preserve tmpArray15(tmpcount15)
            ReDim Preserve tmpArray16(tmpcount16)
            ReDim Preserve tmpArray17(tmpcount17)
            ReDim Preserve tmpArray18(tmpcount18)
            ReDim Preserve tmpArray19(tmpcount19)
            ReDim Preserve tmpArray20(tmpcount20)
            ReDim Preserve tmpArray21(tmpcount21)
            ReDim Preserve tmpArray22(tmpcount22)
            ReDim Preserve tmpArray23(tmpcount23)
            ReDim Preserve tmpArray24(tmpcount24)

            tmpArray3(tmpcount3) = v2entry.ColumnValues(3)
            tmpArray4(tmpcount4) = v2entry.ColumnValues(4)
            tmpArray5(tmpcount5) = v2entry.ColumnValues(5)
            tmpArray6(tmpcount6) = v2entry.ColumnValues(6)
            tmpArray7(tmpcount7) = v2entry.ColumnValues(7)
            tmpArray8(tmpcount8) = v2entry.ColumnValues(8)
            tmpArray9(tmpcount9) = v2entry.ColumnValues(9)
            tmpArray10(tmpcount10) = v2entry.ColumnValues(10)
            tmpArray11(tmpcount11) = v2entry.ColumnValues(11)
            tmpArray12(tmpcount12) = v2entry.ColumnValues(12)
            tmpArray13(tmpcount13)= v2entry.ColumnValues(13)
            tmpArray14(tmpcount14)= v2entry.ColumnValues(14)
            tmpArray15(tmpcount15)= v2entry.ColumnValues(15)
            tmpArray16(tmpcount16)= v2entry.ColumnValues(16)
            tmpArray17(tmpcount17)= v2entry.ColumnValues(17)
            tmpArray18(tmpcount18)= v2entry.ColumnValues(18)
            tmpArray19(tmpcount19)= v2entry.ColumnValues(19)
            tmpArray20(tmpcount20)= v2entry.ColumnValues(20)
            tmpArray21(tmpcount21)= v2entry.ColumnValues(21)
            tmpArray22(tmpcount22)= v2entry.ColumnValues(22)
            tmpArray23(tmpcount23)= v2entry.ColumnValues(23)
            tmpArray24(tmpcount24)= v2entry.ColumnValues(24)

            doccount1 = doccount1 + 1

            tmpcount3=tmpcount3 + 1
            tmpcount4=tmpcount4 + 1
            tmpcount5=tmpcount5 + 1
            tmpcount6=tmpcount6 + 1
            tmpcount7=tmpcount7 + 1
            tmpcount8=tmpcount8 + 1
            tmpcount9=tmpcount9 + 1
            tmpcount10=tmpcount10 + 1
            tmpcount11=tmpcount11 + 1
            tmpcount12=tmpcount12 + 1
            tmpcount13=tmpcount13 + 1
            tmpcount14=tmpcount14 + 1
            tmpcount15=tmpcount15 + 1
            tmpcount16=tmpcount16 + 1
            tmpcount17=tmpcount17 + 1
            tmpcount18=tmpcount18 + 1
            tmpcount19=tmpcount19 + 1
            tmpcount20=tmpcount20 + 1
            tmpcount21=tmpcount21 + 1
            tmpcount22=tmpcount22 + 1
            tmpcount23=tmpcount23 + 1
            tmpcount24=tmpcount24 + 1

            Print #datafileNum%,(tmpArray3(0) & ";" & tmpArray4(0))
            Set v2entry = vc.GetNextEntry(v2entry)

        Loop
    Next
    Close datafileNum%
    Exit Sub
4

1 回答 1

2

将您的条件更改为

Do While doccount1 < 11 AND Not v2entry Is Nothing

v2entry.isValid()只能在 v2entry 是 ViewEntry 时使用。当 v2entry 为 Nothing 时,它会失败。Set v2entry = vc.GetNextEntry(v2entry)这是为最后一个条目执行的情况。

v2entry.isValid()如果在创建 ViewEntryCollection 后可以删除文档,则可以使用。您的代码将如下所示:

Do While doccount1 < 11 AND Not v2entry Is Nothing
    If v2entry.isValid() Then
        ...
    End If
Loop
于 2015-01-30T16:15:36.877 回答