пятница, 27 января 2017 г.

Безопасное удаление из коллекции документов в цикле

Sub Initialize
    
    Dim s As New NotesSession
    Dim db As NotesDatabase       
    Dim doc1 As NotesDocument
    Dim doc2 As NotesDocument
    Set db = s.currentdatabase
    Dim col As NotesDocumentCollection   
    Set col = db.AllDocuments
    Set doc1 = col.getfirstdocument
    
    Do Until (doc1 Is Nothing)
         '... Делаем что-то с документом doc1... 
         Set  doc2 =   col.getnextdocument(doc1)         
         Call doc1.remove(True)
         Set doc1 = doc2
    Loop
    
End Sub

Комментариев нет:

Отправить комментарий