Adding feedback to a textbox as items are deleted

S

steven.shannon

I have created a module that will go through and delete all of the
items in a specified outlook folder. I'm attempting to modify it so
that as the items are being deleted, the status of this process is
updated incrementally in a feedback texbox for the user to view (very
similar Sue Mosher's example program 9.5 in her "Microsoft Outlook
Programming" book). However, each time I run it, it displays the
feedback for the last time I ran it only and not the one currently
running -- almost as if it's caching all of the information from the
previous trial somewhere and displaying it the next time I try and run
it.

In other words, if I ran it yesterday and deleted 300 items in some
folder, and then ran it again today but tried deleting 150 items in a
completely different folder, the feedback displayed is for the deletion
of the 300 items yesterday.

The way I'm doing it: first I run a module that loads and shows the
Progress form that contains the textbox. Then I call DeleteAllEntries
that deletes all the entries in the folder whose path is stored in a
class module. DeleteAllEntries makes calls to UpdateProgress which
handles pushing the timestamp to the textbox in the Progress form.

Here is my code for DeleteAllEntries and UpdateProgress. Please note
that the UpdateProgress sub lives in the code for the Progress form:
_______________________________________________

'Delete all entries in the specified folder
Sub DeleteAllEntries()
Dim objFolder As Outlook.MAPIFolder
Dim numCount As Integer
Dim numDeleted As Integer
Set objFolder = GetFolder(InstPrefs.GetFolderPath)
numCount = objFolder.Items.Count
Progress.UpdateProgress ("Processing " & numCount & " items for
deletion")
For i = objFolder.Items.Count To 1 Step -1
If objFolder.Items.Count Mod 50 = 0 Then
numDeleted = numCount - objFolder.Items.Count
Progress.UpdateProgress ("Deleted " & numDeleted & " of " &
numCount)
End If
objFolder.Items.Item(i).Delete
Next
Progress.UpdateProgress ("Finished deleting " & numCount & " items
from folder")
Set objFolder = Nothing
End Sub
_________________________________________________

'Append timestamp and given text to the progress window
Public Sub UpdateProgress(strUpdate As String)
TextBox1.Value = FormatDateTime(Now, vbShortTime) & vbTab &
strUpdate & Chr(13) & Progress.TextBox1.Value
DoEvents
Me.Repaint
End Sub
__________________________________________________

Hope this makes sense. Any help would be appreciated because I'm
drowning here. Thanks very much in advance.

-Steve Shannon
Lux Scientiae, Inc.
 
M

Michael Bauer

Hi Steve,
completely different folder, the feedback displayed is for the deletion
of the 300 items yesterday.

how do you mean that?

For the first call your UpdateProgress shows the folder´s Items.Count
and the current *time* in short. Where do you know from that it´s the
time of yesterday?
 
S

steven.shannon

Hey Michael,

Apologies, that was more just an example to try to explain what's going
on. The same thing happens if I do two runs a few hours or a few
minutes apart. The information that is printed is that pertaining to
the first run (as evidenced by the timestamps and the counts that is
displayed).

-Steve
 
M

Michael Bauer

Hi Steve,

Now() returns the current date & time as shown in your Systray. If you
get a different time somewhere printed then there is something wrong
with your code. I don´t know how to help you with a sample that you
aren´t using at all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top