Hi,
Habe mit der dll VBEx32 über FTp eine Datei hochgeladen.
Funktioniert auch soweit.
Jetzt will ich aber das angezeigt wie weit das Upload ist.
Erst mal der Code:Option Compare Database
Private Declare Function VBEX_FTPConnect Lib "vbex32.dll" _
Alias "VBFTPCONNECT" ( _
ByVal sServer As String, _
ByVal sUser As String, _
ByVal sPassword As String) As Long
Private Declare Function VBEX_FTPFileUpload Lib "vbex32.dll" _
Alias "VBFTPFILEUPLOAD" ( _
ByVal hSocket As Long, _
ByVal hStatus As Long, _
ByVal sServer As String, _
ByVal sRemoteFile As String, _
ByVal sLocalFile As String, _
ByVal nTransferMode As Long) As Long
Private Declare Function VBEX_FTPStatusCode Lib "vbex32.dll" _
Alias "VBFTPSTATUSCODE" () As Long
Private Sub Befehl0_Click()
Dim sServer As String
Dim hSocket As Long
' Verbindung zum eigenen T-Online FTP-Server herstellen
sServer = "www.tt.de"
hSocket = VBEX_FTPConnect(sServer, "www.tt.de", "")
If hSocket > 0 Then
' JEPP - Verbindung steht ;-)
Else
MsgBox CStr(VBEX_FTPStatusCode()) & " - " & VBEX_FTPStatusMsg()
End If
' Datei-Upload
Dim sLocalFile As String
Dim sRemoteFile As String
Dim nMode As Long
sServer = "www.tt.de"
' Lokale Datei, die hochgeladen werden soll
sLocalFile = "C:\test.txt"
' Dateiname und Verzeichnis auf dem Server
sRemoteFile = "neutest.txt"
' Binary-Übertragung
nMode = 2
' Upload starten
nResult = VBEX_FTPFileUpload(hSocket, txthidden, sServer, _
sRemoteFile, sLocalFile, nMode)
End Sub
' Fortschritsanzeige
Private Sub ShowProgress(picProgress As PictureBox, _
ByVal Value As Long, _
ByVal Min As Long, _
ByVal Max As Long, _
Optional ByVal bShowProzent As Boolean = True)
Dim pWidth As Long
Dim intProz As Integer
Dim strProz As String
' Farben
Const progBackColor = &HC00000
Const progForeColor = vbBlack
Const progForeColorHighlight = vbWhite
' Plausibilitätsprüfungen
If Value < Min Then Value = Min
If Value > Max Then Value = Max
' Prozentwert ausrechnen
If Max > 0 Then
intProz = Int(Value / Max * 100 + 0.5)
Else
intProz = 100
End If
With picProgress
' Prüfen, ob AutoReadraw=True
If .AutoRedraw = False Then .AutoRedraw = True
' Inhalt löschen
picProgress.Cls
If Value > 0 Then
' Balkenbreite
pWidth = .ScaleWidth / 100 * intProz
' Balken anzeigen
picProgress.Line (0, 0)-(pWidth, .ScaleHeight), _
progBackColor, BF
' Prozentanzeige
If bShowProzent Then
strProz = CStr(intProz) & " %"
.CurrentX = (.ScaleWidth - .TextWidth(strProz)) / 2
.CurrentY = (.ScaleHeight - .TextHeight(strProz)) / 2
' Vordergrundfarbe
If pWidth >= .CurrentX Then
.ForeColor = progForeColorHighlight
Else
.ForeColor = progForeColor
End If
picProgress.Print strProz
End If
End If
End With
End Sub
Private Sub txtHidden_Change()
' Fortschritt grafisch anzeigen
Dim lngProgress As Long
Dim lngTotal As Long
Dim sData() As String
sData = Split(txthidden.Text, " ")
lngProgress = Val(sData(0))
lngTotal = Val(sData(2))
ShowProgress picProgress, lngProgress, 0, lngTotal
DoEvents
End Sub So Das ist der Code.
Er bringt dann eine Fehlermeldung:
"benutzerdefinierter Typ nicht definiert"
Habe für die picture Box ein Picture Clip genommen. weil ich nicht weiß was es ist.
Vielleicht hat ja jemand ne Ahnung.
Oder weiß was ich falsch mache.
Mfg Patrick Hennig |