19/07/08 12:35
black93
salve
potete aiutarmi a sviluppare il seguente codice per far si che quando si seleziona nel textbox il file, tramite un button parta il download??Xd
client
Server
potete aiutarmi a sviluppare il seguente codice per far si che quando si seleziona nel textbox il file, tramite un button parta il download??Xd
client
Option Explicit Private ELENCADIR As Boolean Private Sub ElencaFrame_DragDrop(Source As Control, X As Single, Y As Single) End Sub Private Sub Form_Load() Load Client(1) ' Alloca istanza End Sub Private Sub Connetti_Click() If Trim(HostName.Text) = "" Then Exit Sub Unload Client(1) ' Dealloca prima di utilizzare Load Client(1) ' Rialloca istanza Client(1).Connect Trim(HostName.Text), 1500 End Sub Private Sub Disconnetti_Click() Client(1).Close ' Disconnetti End Sub Private Sub AggiornaButton_Click() If Client(1).State <> sckConnected Then Exit Sub ELENCADIR = True If SceltaDIR(0).Value Then Client(1).SendData "DIRF" & vbNewLine If SceltaDIR(1).Value Then Client(1).SendData "DIRS" & vbNewLine If SceltaDIR(2).Value Then Client(1).SendData "DIR" & vbNewLine End Sub Private Sub Client_DataArrival(Index As Integer, ByVal bytesTotal As Long) Dim DATI As String Client(1).GetData DATI, vbString, bytesTotal ' Ricevi If ELENCADIR = True Then PreparaElenco DATI End Sub Private Sub ElencoFiles_DblClick() Client(1).SendData "CD " & ElencoFiles.Text & vbNewLine End Sub Private Sub PreparaElenco(ByVal Elenco As String) Dim INVIO As Integer ELENCADIR = False ElencoFiles.Clear Elenco = Mid(Elenco, InStr(1, Elenco, vbNewLine)) INVIO = InStr(1, Elenco, vbNewLine) If InStr(INVIO + 1, Elenco, vbNewLine) < 1 Then INVIO = 0 While INVIO <> 0 ElencoFiles.AddItem Mid(Elenco, INVIO + 2, InStr(INVIO + 1, Elenco, vbNewLine) - INVIO - 2) INVIO = InStr(INVIO + 1, Elenco, vbNewLine) If InStr(INVIO + 1, Elenco, vbNewLine) < 1 Then INVIO = 0 Wend End Sub
Server
Option Explicit Private DATIINARRIVO As String ' Dati senza invio Private Sub Form_Load() Server.Listen End Sub Private Sub Form_Unload(Cancel As Integer) Server_Close ' Chiusura del server End End Sub Private Sub Server_Close() Server.Close Server.Listen ' Riapre la porta in ascolto StatoConnessione.Caption = "Nessun utente collegato" End Sub Private Sub Server_ConnectionRequest(ByVal requestID As Long) Server.Close Server.Accept requestID ' Accetta connessione DoEvents TimeOut.Enabled = True ' Avvia countdown StatoConnessione.Caption = "Un utente collegato" End Sub Private Sub Server_DataArrival(ByVal bytesTotal As Long) Dim DATI As String TimeOut.Enabled = False On Error Resume Next Server.GetData DATI, vbString, bytesTotal ' Legge buffer DATIINARRIVO = DATIINARRIVO & DATI ' Appende buffer If Right(DATIINARRIVO, 2) = vbNewLine Then GestisciComandi Left(DATIINARRIVO, Len(DATIINARRIVO) - 2) DATIINARRIVO = "" End If TimeOut.Enabled = True ' Azzera countdown End Sub Private Sub TimeOut_Timer() Server_Close TimeOut.Enabled = False End Sub Private Sub GestisciComandi(ByVal COMANDO As String) Dim VALORE As String On Error Resume Next If InStr(1, COMANDO, " ") <= 0 Then Select Case UCase(COMANDO) ' Comandi senza parametri Case "QUIT": Server_Close Case "BYE": Server_Close Case "DIR": LeggiFilesDir CurDir, True, True Case "DIRS": LeggiFilesDir CurDir, True, False Case "DIRF": LeggiFilesDir CurDir, False, True Case Else: Server.SendData " -ERR: Comando sconosciuto -> " & COMANDO & vbNewLine End Select Else ' Comandi con parametri VALORE = Trim(Mid(COMANDO, InStr(1, COMANDO, " ") + 1)) If UCase(Left(COMANDO, InStr(1, COMANDO, " ") - 1)) = "CD" Then ChDir VALORE Server.SendData " +OK: La cartella di lavoro è: " & CurDir & vbNewLine End If End If End Sub Public Sub LeggiFilesDir(ByVal CARTELLA As String, ByVal CARTELLE As Boolean, ByVal FILES As Boolean) Dim ELENCOFILESDIR As String Dim TEMPSTR As String Dim VALIDO As Boolean ELENCOFILESDIR = "" If Right(CARTELLA, 1) = "\" Then CARTELLA = Left(CARTELLA, Len(CARTELLA) - 1) TEMPSTR = Dir(CARTELLA & "\*.*", vbArchive + vbDirectory + vbHidden + vbNormal + vbReadOnly + vbSystem) While TEMPSTR <> "" VALIDO = False If (CARTELLE = True) And (GetAttr(CARTELLA & "\" & TEMPSTR) And vbDirectory) = vbDirectory Then VALIDO = True If (FILES = True) And (GetAttr(CARTELLA & "\" & TEMPSTR) And vbDirectory) <> vbDirectory Then VALIDO = True If VALIDO = True Then ELENCOFILESDIR = ELENCOFILESDIR & vbNewLine & TEMPSTR TEMPSTR = Dir ' Elemento successivo Wend Server.SendData " +OK: " & ELENCOFILESDIR & vbNewLine End Sub
aaa