
Cancelling file writing process during long writes
I think the best thing to do is establish a loop and check for a flag every
so many cycles to see if the user pressed a "Cancel" button that you give
him.
Like:
For i=1 to a zillion
'do some stuff like write to a file
DoEvents 'need this somewhere to make sure you get the keypress and the
flag value setting
If i mod 10 = 0 then ' check every 10 loop cycles
If blnFlag=True then 'see if the user has pressed a 'Cancel' button
Exit Sub
End If
End If
Next i
If you simply start a long process that you do not interrupt with code
(like streaming a long file and not yielding to the system), you won't have
much success.
Dave Burr
Lumisoft
Quote:
> I am just starting off with VB5, and I just want to know how to cancel a
> file write process in response to a keypress during a long file write. I
> have tried to use timer and the doevents to monitor keyboard activity,
but
> I seem to get nowhere.
> I must be doing something very simple wrong.
> Can anyone help?
> Cyprien de Cosson.