DeleteThumbs Example VB

This example demonstrates how to delete all the currently selected thumbnails. It deletes them one at a time, deleting the page from the source first.

Private Sub cmdDelete_Click()
    Dim iPagesDeleted As Integer
    Dim ThumbsToDelete, ThumbCount As Integer    
    iPagesDeleted = 0
    ThumbsToDelete = ImgThumbnail1.SelectedThumbCount  'Get # of selected thumbnails
    TotalThumbs = ImgThumbnail1.ThumbCount
    On Error GoTo ErrDelete
        'Loop until a selected thumbnail is encountered - delete it. Must
        'reset the loop because the thumbcount has changed as well as the
        'index of the next selected thumbnail.
        For i = ImgThumbnail1.LastSelectedThumb To 
            ImgThumbnail1.FirstSelectedThumb Step -1
            If ImgThumbnail1.ThumbSelected(i) = True Then
                ImgAdmin1.DeletePages i, 1  'Must delete pages from 
                                            'image file first
                ImgThumbnail1.DeleteThumbs i, 1
                iPagesDeleted = iPagesDeleted + 1
            End If
        Next i
        'Display a message regarding the status of the delete attempt
        If iPagesDeleted <> ThumbsToDelete Then
            MsgBox "Error deleting pages - " & 
                Str(ImgThumbnail1.StatusCode), , "Thumbnail"
        Else
            MsgBox (Str(ThumbsToDelete) & " of " & Str(TotalThumbs) & " were deleted.")
        End If
    Exit Sub
ErrDelete:
    MsgBox Err.Description, , "Thumbnail"
    Exit Sub
End Sub