Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Communications > Winsocks


Reply
 
Thread Tools Display Modes
  #1  
Old 04-20-2008, 05:13 PM
eltavo eltavo is offline
Newcomer
 
Join Date: Apr 2008
Posts: 1
Question Winsocks


First of all, I think it`s important to point out I`m no expert in VB. So bare with me.

I´m writting a code for a remote file manager. I`ve got the file transfer to work but my problem is in the explorer itself.

My basic idea is to have a FileListBox with all the files in the server side and, on request by the client, with a For i = 0 To Files1.ListCount - 1 make a run over each file and send them to the client. Then, on the client side, add each file name (separating them with a "|") one by one to a ListBox with a split function.

Here is the code:

Server Side:
Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim Y As String
Dim X As String

Winsock1.GetData X, vbString
Y = Right(X, 100)
X = Left(X, 1)

Select Case X

Case "1" ' This is for files
    For i = 0 To Files1.ListCount - 1
        x = Files1.List(i) & "|" & x       
    Next i
Winsock1.SendData "File" & x

Case "2" ' This is for folders
    For i = 0 To Dire.ListCount - 1
        x = Dire.List(i) & "|" & x       
    Next i
Winsock1.SendData "Dire" & x

End Select

End Sub
On the client side:
Code:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim X As String
Dim Y As String
Dim Z As String

Winsock1.GetData X, vbString

Y = Right(X, 100)
Z = Left(X, 4) 

Select Case Z

Case "Dire"
Y = Right(Y, Len(Y) - 4)

Dim fields() As String
fields() = Split(Y, "|")

For i = 0 To UBound(fields)
    List2.AddItem Trim$(fields(i))
Next
End If

Case "File"
Y = Right(Y, Len(Y) - 4)

Dim fields() As String
fields() = Split(Y, "|")

For i = 0 To UBound(fields)
    List1.AddItem Trim$(fields(i))
Next
End If

End Select

End Sub
Reply With Quote
  #2  
Old 04-20-2008, 11:52 PM
DougT's Avatar
DougT DougT is offline
Ultimate Antique

Administrator
* Expert *
 
Join Date: Sep 2005
Location: Maldon,Essex, UK
Posts: 3,939
Default

and your question / problem is ...... ?

Let me guess, you're not getting complete information back or it is corrupted ?
__________________
semel insanivimus omnes
S Data in context = Information, S Information in context = Knowledge, S Knowledge in context = Experience
S Experience in context = Wisdom= Data
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->