Go Premium for a chance to win a PS4. Enter to Win

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

Sending a List Through Winsock

How do u send a list through winsock!!!

The layout of my app.


Private Sub CmdConnect_Click()
tcpclient.Connect txtip.Text, 3500
End Sub

Private Sub CmdCollect_Click()
tcpclient.SendData "msg"
' Here i want the code to send the drive's ------------------------------------
End Sub


Private Sub Form_Load()
End Sub

Private Sub tcpServer_ConnectionRequest(ByVal requestID As Long)
tcpServer.Accept requestID
End Sub

Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)
Dim vardata As String
Dim strdata As String
Dim cmddata As String * 3
tcpServer.GetData strdata
cmddata = Left(strdata, 3)
vardata = Right(strdata, Len(strdata) - 3)
DoCommand cmddata, vardata
End Sub

Private Sub tcpServer_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
On Error Resume Next
End Sub

Module 1

Public Function DoCommand(command As String, Data As String)  

Case "msg"
Msgbox "Connected, Requesting Sending Drive List"
' Here i want the code to accept the drive list and add it to a list -----------------------------
End Select
End Function

I want the client to send the case msg which it does then the Client to send the drive list from the form.
The Drive list is frmclient.Drive1
The List on the Server is

Thanx in Advance
1 Solution
Well i dont know how your planing to get ther drive list but sending the list is simple

*** This Sub creates the list to send
Private Sub CreateList() as String
Dim Total as Integer
Dim Done as Integer
Dim Whole as String
Total = *** insert toal number of drives (or whatever). Ill use Driver(index) from now on
Done = 0
Do until Total = Done
      Whole = Whole & Driver(Done) & VbTab
      Done = Done + 1
CreateList = Whole
End Function

*** This Sub Splits the List
Private Sub GetList(Whole as String)
Dim Temp as String
Dim Asci as Integer
Dim Drive as Integer
Do Until Len(Whole) = 0
      Temp = Left(Whole, 1)
      Whole = Right(Whole, Len(Whole) - 1)
      If Asci <> 9 Then
            Drive = Drive & Temp
      End If
      If Asci = 9 Then
            lstDrives.AddItem Drive *** This is where you use the information to do whaterver (this one puts it in a list box)
      End If
End Sub

*** This Code Is For Recieving The Information
Private Sub wskClient(ByVal bytesTotal As Long)
Dim Whole as String
Dim Temp as String
wskClient.GetData Whole
Temp = Left(Whole, 4)
Whole = Right(Whole, Len(Whole) - 4)
Select Case Temp
      Case "DVL_"
      Case Else
            Debug.Pring Whole
End Select
End Sub

All  the code is there that you will need just some of it you may need to change to suit the way you get the drive information.
A word of warning, i have done this code of the top of my head (comp didnt have VB), it should work.

Any questions just ask

Jonothan Tompson

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now