Oppure

Loading
12/02/07 22:54
Ciao a tutti sto realizzando un progettino, Client / Server.

Nel Server ho impostato un Combo, un Drive, un Dir e un File..

Due List1, List2

Option Explicit
Dim k, d, f As Integer
Dim Drive(0 To 100) As String
Dim file(0 To 200) As String
Dim dir(0 To 150) As String
Private Sub Combo1_Click()
On Error GoTo error
Drive1.Drive = Combo1.List(Combo1.ListIndex)
error:
End Sub
Private Sub Dir1_Change()
On Error Resume Next
File1.Path = Dir1.Path
Call Aggiorna
End Sub
Private Sub Drive1_Change()
On Error GoTo error_handler
Dir1.Path = Drive1.Drive
error_handler:
End Sub
Private Sub Aggiorna()
List1.Clear
List2.Clear
For k = 0 To (Drive1.ListCount - 1)
Drive(k) = Drive1.List(k)
Combo1.List(k) = Drive(k)
Next k
List1.AddItem ("..";)
For d = 0 To (Dir1.ListCount - 1)
dir(d) = Dir1.List(d)
List1.List(d + 1) = dir(d)
Next d
For f = 0 To (File1.ListCount - 1)
file(f) = File1.List(f)
List2.List(f) = file(f)
Next f
End Sub
Private Sub Form_Load()
Call Aggiorna
End Sub
Private Sub List1_dblClick()
On Error GoTo error
Dir1.Path = List1.List(List1.ListIndex)
error:
End Sub

Nel List1 mi visualizza tutte le directory.. e nel List2 i files!

Uso Winsock.. Ovvio.. ma vorrei capirne di +

Per inviare la List1 al Client, in che modo posso farlo?

Qualcuno mi può dare una mano..

grazie..
Ultima modifica effettuata da 12/02/07 22:57
13/02/07 13:31
P4p3r0g4
Postato originariamente da motoboy:
...
Dim Drive(0 To 100) As String
Dim file(0 To 200) As String
Dim dir(0 To 150) As String
...
Nel List1 mi visualizza tutte le directory.. e nel List2 i files!

Uso Winsock.. Ovvio.. ma vorrei capirne di +
Per inviare la List1 al Client, in che modo posso farlo?

puoi farlo in vari modi. o invii ogni volta con winsock stringhe tipo "fle1:" e poi il file in modo che il client riconosca la posizione e dove vada la stringa che gli stai passando, o con stringe di inizio e fine tipo "file : 5" e nei 5 senddata seguenti invii i 5 contenuti della variabile file(x) (ponendo ad esempio che ce ne siano 5).
aaa
13/02/07 16:14
Hacker
io invierei i dati con parole chiavi seguite da ":" con immediatamente il valore.
(Es. file:C:\ciao.txt )

Esempio per i files.

Uno invia:
winsock.senddata "file:C:\ciao.txt"

e l'altro interpreta:

If InStr(1, DatiRicevuti, "file:", vbTextCompare) <> 0 Then

MyFilePath = Mid(DatiRicevuti, 6)

End If

Ok?
Ultima modifica effettuata da Hacker 13/02/07 16:20
aaa
13/02/07 16:43
P4p3r0g4
si pero direi anche la posizione così quando la clicco sulla listbox per cambiare non ho la lista delle diretory sfasata.
aaa
14/02/07 1:12
Option Explicit
Dim k, d, f As Integer
Dim Drive(0 To 100) As String
Dim file(0 To 200) As String
Dim dir(0 To 150) As String
Private Sub Combo1_Click()
On Error GoTo error
Drive1.Drive = Combo1.List(Combo1.ListIndex)
error:
End Sub
Private Sub Dir1_Change()
On Error Resume Next
File1.Path = Dir1.Path
Call Aggiorna
End Sub
Private Sub Drive1_Change()
On Error GoTo error_handler
Dir1.Path = Drive1.Drive
error_handler:
End Sub
Private Sub Aggiorna()
List1.Clear
List2.Clear
For k = 0 To (Drive1.ListCount - 1)
Drive(k) = Drive1.List(k)
Combo1.List(k) = Drive(k)
Next k
List1.AddItem ("..";)
For d = 0 To (Dir1.ListCount - 1)
dir(d) = Dir1.List(d)
List1.List(d + 1) = dir(d)
Next d
For f = 0 To (File1.ListCount - 1)
file(f) = File1.List(f)
List2.List(f) = file(f)
Next f
End Sub
Private Sub Form_Load()
Call Aggiorna
End Sub
Private Sub List1_dblClick()
On Error GoTo error
Dir1.Path = List1.List(List1.ListIndex)
error:
End Sub

questo é quello che ho impostato..

da quello che ho letto..

ogni componente che ho inserito, alla fine devo inserire questo Invio al Client..
ma é un procedimento che ho già svolto..

in questo modo

Private Sub Combo1_Click()
On Error GoTo error
Drive1.Drive = Combo1.List(Combo1.ListIndex)
If winsock.state = sckConnected Then
winsock.SendData "drive"
End if
error:
End Sub

dite in questo modo, per ogni componente?

grazie... ancora

vorrei ulteriori spiegazioni!
14/02/07 16:31
P4p3r0g4
no noi diciamo più un
for k = 0 to file.listcount -1
wsk.senddata = "file:" & k & ":" & file.list(k)
next k
for k = 0 to drive.listcount -1
wsk.senddata = "drive:" & k & ":" & drive.list(k)
next k
for k = 0 to dir.listcount -1
wsk.senddata = "dir:" & k & ":" & dir.list(k)
next k


all'invio e una comparazione e ricavo di dati in ricezione
aaa
14/02/07 17:05
no noi diciamo più un
for k = 0 to file.listcount -1
wsk.senddata = "file:" & k & ":" & file.list(k)
next k
for k = 0 to drive.listcount -1
wsk.senddata = "drive:" & k & ":" & drive.list(k)
next k
for k = 0 to dir.listcount -1
wsk.senddata = "dir:" & k & ":" & dir.list(k)
next k


all'invio e una comparazione e ricavo di dati in ricezione

Grazie per la risposta..

la mia domanda é..

le tue istruzioni mi consigli di metterli nell 'aggiorna?

cioè qui..

Private Sub Aggiorna()
List1.Clear
List2.Clear
For k = 0 To (Drive1.ListCount - 1)
Drive(k) = Drive1.List(k)
Combo1.List(k) = Drive(k)
Next k
List1.AddItem ("..";)
For d = 0 To (Dir1.ListCount - 1)
dir(d) = Dir1.List(d)
List1.List(d + 1) = dir(d)
Next d
For f = 0 To (File1.ListCount - 1)
file(f) = File1.List(f)
List2.List(f) = file(f)
Next f
End Sub

e quindi..

o nel List1 dove mi legge le directory ?

In che modo li leggo nel Client ?

Nel client ho impostato un componente.. un List

List1

grazie ancora per la risposta..
15/02/07 13:03
P4p3r0g4
in public sub list_dblclick()
aaa