No probs,
First of all. By putting DoEvents in side a loop, you are allowing the system to continue doing the things that it normally does while the loop is executing.
If you leave it out, you are effectively stopping the program and parts of the system from continuing execution.
And the code explanation is below
Code:
'=======================================================
'Check the RIGHTMOST EIGHT characters of the received
'Data to see if they contain a command sent from the
'Client Program (If you look at the client, you will
'see that the code for 'User has Connected' Has Been
'Removed and a simple SendData put in it's place with
'Characters at the end to identify it as a Client Log on
'=======================================================
If Right(strdata, 8) = "*STARTUP" Then
'=================================================
'Add the User Connected line to the list box using
'the characters from the SendData MINUS the
'Identifying Characters at the end...
'=================================================
lstMsg.AddItem "User: '" & Mid(strdata, 1, Len(strdata) - 8) & _
"' Has Connected"
'==============================================
'Exit Routine Early, So nothing else is printed
'==============================================
Exit Sub
End If
Y'See, normally you would just send text with the SendData Command, however if you add characters to the end (or start) of the SendData Text String, you can set up recognition by the receiving computer to do DIFFERENT things instead of displaying them as text in the box...
For Instance..
You could have different identifying characters for Gestures instead of text in the program
e.g. ACTION*Needs A Smile
could be sent,
and the receiving computer, before processing the received data, could check whether the first 7 Characters say ACTION*. And if so, print it in the box like:
Jag14 Needs A Smile
instead of
Jag14: How You Doin?
The modification can be made to the code above by putting an ELSEIF Statement Just before the END IF.
Code:
ElseIf Left(strData, 7) = "ACTION*" Then
lstMsg.AddItem USERNAME & _
mid(strdata, 8, len(strdata) - 7)
Exit Sub
End If
Now you should be able to get an idea of where to start from, you can build a fully featured chat program with WinSock. Use it wisely grasshopper...
Hope it Helps...
[tt]'Very funny, Scotty... Now Beam down my clothes.'[/tt]