Quote Originally Posted by Karimz
how does it know that the LISTU= case is the one for the combobox thingy while the MSGBX= is for the msgbox ?
VB Code:
  1. dataCommand$ = Left$(dataRecieved, Len(dataRecieved$) - Len(dataRecieved$) + 6)
  2.       realData$ = Right$(dataRecieved$, Len(dataRecieved$) - 6)

This is the part where we seperate the data we want, from the command that seperates each case. Like if our data was:

"MSGBX=Hello"

dataCommand$ deletes the actual data and leaves just the Command.
realData$ deletes the command, btu leaves the data we want to display.

Now that this is done we can put them into cases and give them each stuff to do. This is how it knows what to do, you can add more cases if you want.

Sorry, and I made another mistake, this should work:

VB Code:
  1. Private Sub Command1_Click()
  2. 'put each item into an arr$, the delimiter (seperator) is ||||, on the client
  3.  Dim arr As String, i As Integer
  4.    'put all the data into an array string, we will seperate this once recieved at client
  5.   For i% = 0 To cboServer.ListCount - 1
  6.     If Len(arr$) = 0 Then
  7.        arr$ = cboServer.ListCount & "||||" & cboServer.List(i%)
  8.           Else
  9.        arr$ = arr$ & "||||" & cboServer.List(i%)
  10.     End If
  11.   Next i%
  12.      sckServer.SendData arr$ 'send the data to the client
  13. End Sub
  14.  
  15. Private Sub sckClient_DataArrival(ByVal bytesTotal As Long)
  16.   Dim str As String
  17.  
  18.     'put the data recieved into str$
  19.       sckClient.GetData str$, vbString
  20.  
  21.     'evaluate the data recieved from the client
  22.       EvaluateData& str$
  23.  
  24. End Sub
  25.  
  26. Function EvaluateData(ByVal dataRecieved As String) As Long
  27.  
  28.  Dim tmp() As String, i As Integer
  29.     'the actual data is after the first 6 characters, for example:
  30.     'LISTU=the rest of the data recieved, LISTU stands for LIST UPDATE
  31.    'dataCommand is the command sent by the client, like LISTU,
  32.    'realData is the data after the dataCommand, the actual data we want.
  33.  
  34.       Dim dataCommand As String, realData As String
  35.       dataCommand$ = Left$(dataRecieved, Len(dataRecieved$) - Len(dataRecieved$) + 6)
  36.       realData$ = Right$(dataRecieved$, Len(dataRecieved$) - 6)
  37.          Select Case dataCommand$
  38.             Case "LISTU="
  39.               'seperate each with Split()
  40.                    tmp$() = Split(realData$, "||||")
  41.                   'tmp$(0) is the ListCount
  42.                      For i% = 1 to CInt(tmp$(0)) - 1
  43.                        cboClient.AddItem tmp$(i%)
  44.                      Next i%
  45.              Case "MSGBX="
  46.                MsgBox realData$, vbOkOnly + vbSystemModal, "My Project"
  47.          End Select
  48.  
  49. End Function