Bueno Hola a todos:
Tengo un codigo que me baje de un cliente/servidor para transferir archivos.El servidor manda al cliente un archivo y cuando lo manda al cliente en el servidor se visualiza un
ProgressBar del transcurso de la transferencia. Yo lo que queria es si se puede visualizar el ProgressBar en el cliente.
Gracias
Servidor:
Private Sub Command1_Click()
Common.DialogTitle = "Buscar archivo..."
Common.FileName = ""
Common.Filter = "Todos los archivos|*.*"
Common.ShowOpen
If Common.FileName <> "" Then
Label2.Caption = Common.FileName
Open Label2.Caption For Binary As #1
TCP.SendData "EMA" & Common.FileTitle & "LAR" & LOF(1) 'envio nombre y largo de archivo
Close #1
End If
On Error GoTo ema
Dim Buf As String * 1024
Dim Todo As String
Open Label2.Caption For Binary As #1
Barra.Min = 0
Barra.Max = LOF(1)
Do While Not EOF(1)
DoEvents
Get #1, , Buf
Todo = Todo & Buf
If Len(Todo) <= Barra.Max Then Barra.Value = Len(Todo)
Loop
Close
TCP.SendData Todo
Exit Sub
ema:
MsgBox Err.Description
End Sub
Private Sub TCP_SendProgress(ByVal bytesSent As Long, ByVal bytesRemaining As Long)
Barra.Min = 0
Barra.Max = bytesSent + bytesRemaining
Barra.Value = bytesSent
End Sub
Cliente:
Private Sub TCP_DataArrival(ByVal bytesTotal As Long)
Dim Texto As String
TCP.GetData Texto
If Mid(Texto, 1, 3) = "EMA" Then
cargo_Datos Texto
Exit Sub
End If
If Mid(Texto, 1, 3) = "LAR" Then
Frame1.Caption = "Archivo : " & Mid(Texto, 4, Len(Texto) - 3) & " bytes."
Largo = CLng(Mid(Texto, 4, Len(Texto) - 3))
Exit Sub
End If
Archivo = Archivo & Texto
If Len(Archivo) >= Largo Then
Common.DialogTitle = "Guardar archivo..."
Common.FileName = Label1.Caption
Common.ShowSave
Open Common.FileName For Binary As #1
Put #1, , Archivo
Largo = 0
Archivo = ""
Close #1
End If
End Sub
Sub cargo_Datos(Txt As String)
Dim i As Long
Dim Nom As String
Txt = Mid(Txt, 4, Len(Txt) - 3)
For i = 1 To Len(Txt)
If Mid(Txt, i, 3) = "LAR" Then
Nom = Left(Txt, i - 1)
Largo = CLng(Mid(Txt, i + 3, Len(Txt) - i))
Label1.Caption = Nom
Frame1.Caption = "Archivo : " & Largo & " bytes..."
End If
Next i
End Sub