It would be basically the same thing except each winsock will have it's own SendComplete event. Only in the last socket to send a closing message SendComplete event will you check for SentClosing.
Code:' Dim SentClosing As Boolean ' ' Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) If unloadmode = vbFormControlMenu And Not SentClosing Then If sckAdam.State = sckOpen Or sckAdam.State = sckConnected Then sckAdam.SendData "Closing" End If ' ' etc, etc for all sockets ' If sckZebra.State = sckOpen Or sckZebra.State = sckConnected Then sckZebra.SendData "Closing" End If SentClosing = True cancel = True End If End Sub ' ' ' ' First socket to close ' Private Sub sckAdam_SendComplete() If SentClosing Then sckAdam.Close Else '... other existing logic... End If End Sub ' ' etc, etc ' ' ' Last socket to close ' Private Sub sckZebra_SendComplete() If SentClosing Then sckZebra.Close Unload Me Else '... other existing logic... End If End Sub




Reply With Quote