Necesito añadir un progressbar a mi aplicacion. La verdad es que ya tengo medio trabajo hecho, pero no entiendo por que no sigue al compas de la entrada de datos.
os posteo el codigo:
Case "descarga"
On Error Resume Next
sizefile = datos
PB.Max = sizefile
sizefilerecibido = sizefilerecibido + bytesTotal 'Variable que aumenta cuando put coge datos
PB.Value = sizefilerecibido ' esta es la barra de progreso.
Put #2, , datos
If Right(datos, 3) = "Fin" Or datos = "Fin" Then
If sizefilerecibido >= sizefile Then
Close #2
sizefilerecibido = 0
PB.Value = PB.Max
MsgBox "Descarga Finalizada", vbOKOnly
End If
PB.Value = 0
End If
End Select
Select Case datos
Case "error 76"
MsgBox "La Ruta introducida no es correcta.", vbOKOnly
Close #2
Case "error 68"
MsgBox "La Unidad no esta disponible.", vbOKOnly
End Select
echalo completo
Mirad camaradas, tengo el siguiente codigo en mi aplicacion y no consigo hacer que mi progress bar funcione y no se por que.
Espero me podais ayudar.
CLIENTE:
Private Sub btdescarga_Click() 'boton que le dice al servidor que inicia la descarga del archivo de esa ruta que hemos introducido en un txtbox
rutadestino = "C:\Documents and Settings\Armando_Bollos\Mis documentos\Mis archivos recibidos\Archivos Recibidos\" & fileselect
Open rutadestino For Binary As #2
y = "tamaño-"
wc.SendData y & txtruta.Text 'enviamos la ruta del archivo al server.
donde = "tamaño" 'Le pedimos que mande el resultado al case tamaño del datarrival
LLEGADA AL SERVER DE LA INFORMACION:
Case "tamaño"
rutafile = vdatos(1) ' vdatos(1) contiene la ruta del archivo que queremos abrir y calcular el tamaño
Call tamaño ' llamada a la funcion para calcular el tamaño
Private Sub tamaño()
Dim size As String
Open rutafile For Binary Access Read As #3 ' abrimos el archivo que contiene el rutefile que hemos enviado
size = CStr(LOF(3)) ' calculamos su tamaño
Close #3
ws.SendData size ' Envia al cliente el tamañodel archivo
End Sub
LLEGADA AL CLIENTE DE LA INFORMACION:
Case "tamaño"
tamañofile = datos 'Meto en esa variable el tamaño del archivo
PB.Min = (datos - datos) ' Pongo el minimo de la barra de pregreso
PB.Max = datos ' pongo el maximo de la barra de progreso
PB.Value = PB.Min ' establezco el valor de la barra de progreso
sizefilerecibido = 0 ' establezco el valor que ira sumando los bytes que vayan entrando
y = "descarga-"
wc.SendData y & txtruta.Text 'envio al server que puede empezar a enviar datos
donde = "descarga"
LLEGADA DE DATOS AL SERVER :
Case "descarga" 'caso para empezar a enviar los datod del file
On Error GoTo errores
Dim tamañofile As Long
rutafile = vdatos(1)
Open rutafile For Binary Access Read As #2
tamañofile = LOF(2)
ReDim file(tamañofile - 1)
Get #2, , file
ws.SendData file
ws.SendData "Fin"
Close #2
End Sub
LLEGADA DE DATOS AL CLIENTE:
Case "descarga"
On Error Resume Next
Put #2, , datos
sizefilerecibido = sizefilerecibido + bytesTotal 'Sumo a la variable los datos que van entrando
PB.Value = sizefilerecibido 'asigno el valor de la variable al valor de la progres bar
If Right(datos, 3) = "Fin" Or datos = "Fin" Then
If sizefilerecibido >= sizefile Then
Close #2
sizefilerecibido = 0
PB.Value = PB.Max
MsgBox "Descarga Finalizada", vbOKOnly
End If
PB.Value = 0
End If
Espero me podais ayudar. Un saludo. Muchas gracias.
E usado progres bar antes.. y si no estoy mal.. las progres bar necesitan valores de tamanio.. asi como..
ProgresBar.Min.Value = 1
ProgresBar.Max.Value = 100