ProgressBar trop rapide ! CECI EST URGENT SVP !

zebest3000 Messages postés 20 Date d'inscription samedi 12 octobre 2002 Statut Membre Dernière intervention 9 novembre 2002 - 9 nov. 2002 à 15:46
zebest3000 Messages postés 20 Date d'inscription samedi 12 octobre 2002 Statut Membre Dernière intervention 9 novembre 2002 - 9 nov. 2002 à 20:56
Ma ProgressBar va hyper vite alors qu'elle ne devrait pas !
En fait ma ProgressBar doit être proportionnel à l'envoie du fichier, alors que là, elle est fini avant même que le fichier ne soit complètement envoyé !

[...]
strAddress = "127.0.0.1"
strUserID = "login"
strPassword = "password"
strLocalFile = "c:\text.txt"
strRemoteFile = "text.txt"
[...]
lngSessionHandle = InternetOpen("Default Site", INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, INTERNET_FLAG_NO_CACHE_WRITE)
If lngSessionHandle <> 0 Then
lngServerHandle = InternetConnect(lngSessionHandle, strAddress, INTERNET_INVALID_PORT_NUMBER, strUserID, strPassword, INTERNET_SERVICE_FTP, INTERNET_FLAG_EXISTING_CONNECT Or INTERNET_FLAG_PASSIVE, &H0)
If lngServerHandle = 0 Then
'ErreurMSG
Exit Sub
End If
Else
'ErreurMSG-Session
Exit Sub
End If
[...]
lngFileLength = FileLen(strLocalFile)

With ProgressBar1
.Value = 0
.Min = 0
.Max = lngFileLength
.Refresh
End With

If blAppend = True Then
lngReturn = FtpCommand(lngServerHandle, True, FTP_TRANSFER_TYPE_ASCII, "APPE " & strRemoteFile, 0, lngFileHandle)
If lngReturn = 0 Then
'ErreurMSG-Create
Exit Sub
End If
Else
lngFileHandle = FtpOpenFile(lngServerHandle, strRemoteFile, GENERIC_WRITE, FTP_TRANSFER_TYPE_ASCII, 0)
If lngFileHandle = 0 Then
'ErreurMSG-Create
Exit Sub
End If
End If

sngBaudRate = 0
lngSentBytes = 0
lngSentLength = 0
lngStartTime = GetTickCount

intFreeFile = FreeFile
Open strLocalFile For Binary As intFreeFile
lngFileLength = LOF(intFreeFile)
Do
Get #intFreeFile, , strBuffer
If lngSentLength < lngFileLength - cBufferSize Then
If InternetWriteFile(lngFileHandle, strBuffer, cBufferSize, lngReturn) = 0 Then
'ErreurMSG-Write
Exit Do
End If
lngSentBytes = lngSentBytes + cBufferSize
lngSentLength = lngSentLength + cBufferSize
Else
If InternetWriteFile(lngFileHandle, strBuffer, lngFileLength - lngSentLength, lngReturn) = 0 Then
'ErreurMSG-Write
Exit Do
End If
lngSentBytes = lngSentBytes + (lngFileLength - lngSentLength)
lngSentLength = lngFileLength
End If
ProgressBar1.Value = lngSentLength
DoEvents
Loop Until lngSentLength >= lngFileLength
Close #intFreeFile
[...]

2 réponses

cs_visualbasic Messages postés 44 Date d'inscription vendredi 25 janvier 2002 Statut Membre Dernière intervention 13 avril 2004
9 nov. 2002 à 19:25
remplace ta ligne par celle ci

progressBar1.value=ProgressBar1.value + 1
0
zebest3000 Messages postés 20 Date d'inscription samedi 12 octobre 2002 Statut Membre Dernière intervention 9 novembre 2002
9 nov. 2002 à 20:56
ça ne marche pas comme ceci... :-(
Quelqu'un aurait qlq chose svp ?
0
Rejoignez-nous