p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Beginning VB 6 (http://p2p.wrox.com/forumdisplay.php?f=75)
-   -   how about cancel a process (http://p2p.wrox.com/showthread.php?t=38377)

kevsboy February 12th, 2006 11:03 PM

how about cancel a process
 
I am currently working on an application where it converts a CSV infile into another format of CSV outfile. In a nutshell, the application reads#12288;from the infile, then process (around 10thousand records), then writes to an outfile. The routine process the input line by line.

Private Sub convertFile(textBoxNumber As String)
   Do Until EOF(1)
     'read the file, then process, then write
   Loop
end sub

What if during the process, the user wants to cancel the job? I tried putting a DoEvent with a GetInputState inside the Loop:

Private Sub convertFile(textBoxNumber As String)
   Do Until EOF(1)

     If GetInputState() <> 0 Then
       DoEvents
       If MsgBox("Conversion Completed upto routine " & i & ". Cancel the rest?", vbQuestion + vbYesNo) = vbYes Then EXIT SUB
     End If

     'read the file, then process, then write
   Loop
end sub

It did catch the key press event, but the problem is, it catches the key pressed after the loop was done. Defeats the purpose because what if the infile is really big. What I am hoping for is some what a real time action on the key press.

Thanks for the advice. If my approach seems to be wrong or absurd, that's because I am a new user of VB. Please excuse me. Thanks guys!





All times are GMT -4. The time now is 10:05 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.