源代碼如下:(希望解決的問題1、提供list表單,將登錄ftp路徑下的檔案或檔案夾顯示出來;2、增加下載的判斷,特別是下載完一個檔案后程式不在有動作了再下載下一個檔案。)折騰好幾天了,還沒搞定。先謝謝了。
Private Sub Command1_Click()
Dim report_date As Date '定義公共日期
Dim check_i As Integer
check_i = 1
Dim path_hd As String '定義讀取路徑
Dim path_namehd As String '定義名字
Dim hdfile_head As String
path_hd = "//hd/"
hdfile_head = "HD"
path_namehd = "邯鄲公司"
report_date = DTPicker1.Value - 1
Call check_report(path_hd, path_namehd, report_date, hdfile_head, check_i)
End Sub
Sub check_report(path As String, name As String, pre_date As Date, file_head As String, excel_i As Integer)
Dim str_together As String
Dim filehead_together As String
Dim reach_record As String
Dim disreach_record As String
filehead_together = filehead_together + Format(pre_date, "YYYYMMDD")
str_together = path + Format(pre_date, "YYYYMMDD")
'Debug.Print str_together
Inet1.URL = "192.168.2.11/"
Inet1.UserName = "xiexie"
Inet1.Password = "zhbxst"
onerr goto Proc_Exit:
Inet1.AccessType = icUseDefault '設定與Internet連接的型別,默認值
Inet1.Protocol = icFTP
Inet1.RemotePort = 21
Inet1.Cancel
On Error GoTo Proc_Exit
Inet1.Execute Inet1.URL, "dir " & "/"
Do While Inet1.StillExecuting
DoEvents
Loop
Inet1.Execute Inet1.URL, "GET " & str_together & ".xls " & App.path & "\" & file_head & filehead_together & ".xls"
Do While Inet1.StillExecuting
DoEvents
Loop
If Dir(App.path & "\" & file_head & filehead_together & ".xls") = "" Then
Open App.path & "\jkrb.txt" For Append As #1
Print #1, reach_record
Close #1
Else
disreach_record = disreach_record + name & "jkrb"
Open App.path & "\jkrb.txt" For Append As #1
Print #1, disreach_record
Close #1
End If
Proc_Exit:
If Err.Number = -2147467259 Then
' Resume
MsgBox "資料庫連接失敗,請檢查網路環境,程式退出!!~", 16, "錯誤"
End
'Fpross.StatusBar1.Panels(1) = "資料庫連接失敗!"
ElseIf Err.Number = 35754 Then
MsgBox "FTP服務器連接失敗,請檢查網路環境,程式退出!", 16, "錯誤"
End
End If
End Sub
uj5u.com熱心網友回復:
自己頂一下吧。uj5u.com熱心網友回復:
比較著急,高手指教一下。uj5u.com熱心網友回復:
謝謝分享,學習一下。轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/131283.html
標籤:控件
下一篇:CodeSmart 引數如何換行
