Hi,

I asked a similar question recently and implemented the various suggestions that I received but, I ran into an unexpected problem which I did not explain in the first post..

Here's the situation:

I have a form which has 2 buttons. cmdStart and cmdCancel. As you can probably already guess, the cmdStart starts the process and cmdCancel cancels the process.

I used the following code behind the cmdCancel button:

Code:
    xVar = MsgBox("Are you sure you wish to cancel downloading?", _
        vbQuestion + vbYesNo)
    
    If xVar = 6 Then
        '-- cancel download operation
        If Winsock1.State <> sckClosed Then
            Winsock1.Close 'close socket if open
        End If
        Unload Me
    End If
However, the code behing cmdStart is "modular" in nature. For example:

cmdStart calls a sub which does some various processing, calls another function to get a value, takes that value and does a calculation, etc...

I beleive that the above CANCEL code would in fact work if the code behind cmdSend was not modular in nature. But, the fact is that I am using modular programming so the above cancel code raises various errors througout the various functions/subs depending on where the fucntion/sub was when the user hit the Cancel button. I do not want to put an error handling routine in each function/sub that cmdStart calls to handle the cancelling.. I'm sure there is a better way to handle "Cancelling" in modular programming..

Does anyone have any ideas on how to easily and "effeciently" cancel processing when you're dealing with modular programming?

Thanks,

Dan