Cancelling file writing process during long writes 
Author Message
 Cancelling file writing process during long writes

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.



Sat, 03 Jun 2000 03:00:00 GMT  
 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.



Sun, 04 Jun 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. overlapping during Read file and write file

2. VB -- Long File Name , Fast Binary File Read / Write , interface with DLL

3. write log file as system during logon?

4. Writing a VBS file which reads and writes to the registry

5. Writing Templates from Webclass doesn't write entire htm file

6. Writing comma delimited text files using double quotes - Write Statement

7. VB5 hangs during exe writing

8. VB5 hangs during exe writing

9. write and run code during runtime

10. Animation during disk write loop

11. Animation during disk write loop

12. Animation during disk write loop

 

 
Powered by phpBB® Forum Software