以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助] 窗口进度条不动态显示??  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=112850)

--  作者:lmlptj
--  发布时间:2018/1/4 9:03:00
--  [求助] 窗口进度条不动态显示??

图片点击可在新窗口打开查看此主题相关图片如下:2.jpg
图片点击可在新窗口打开查看


以下代码是窗口的AfterLoadg事件代码,想实现本地电脑的附件文件与FTP上的文件同步(FTP连接没有问题),且在同步时显示同步了哪些文件,并用进度条显示同步进度。但以下代码只有同步完最后一个文件时才显示,请老师帮忙!!拜谢!


\'\'\'

Dim lb1 As WinForm.Label = e.Form.Controls("Label1")
Dim btn As WinForm.Button = e.Form.Controls("Button1")
btn.Visible = False
Dim pros As WinForm.ProgressBar = e.Form.Controls("ProgressBar1")
pros.Minimum = 1
pros.Value = 1

Dim ftp As New  FTPClient    \'定义FTP客户端
ftp.Host="*******"    \'ip地址
ftp.Account = "****"      \'用户名
ftp.Password = "****"     \'密码
ftp.RootDir = "/儿童附件/"
pros.Maximum = ftp.GetFileList.Count + 1

For Each fl As String In ftp.GetFileList
    If FileSys.FileExists(ProjectPath & "RemoteFiles\\" & fl) = False Then
        Application.DoEvents
        lb1.Text = "正在同步:" & fl
        ftp.Download(fl,ProjectPath & "RemoteFiles\\" & fl)
    End If
    pros.Value = pros.Value +1
Next

btn.Visible = True

--  作者:有点甜
--  发布时间:2018/1/4 10:07:00
--  

试试

 

For Each fl As String In ftp.GetFileList
    If FileSys.FileExists(ProjectPath & "RemoteFiles\\" & fl) = False Then
        Application.DoEvents
        lb1.Text = "正在同步:" & fl
        ftp.Download(fl,ProjectPath & "RemoteFiles\\" & fl)
    End If
    pros.Value = pros.Value +1
    Application.DoEvents
Next

--  作者:lmlptj
--  发布时间:2018/1/4 10:23:00
--  
仍依旧呢图片点击可在新窗口打开查看
--  作者:有点甜
--  发布时间:2018/1/4 11:03:00
--  

测试下面代码,看弹出什么

 

Dim lb1 As WinForm.Label = e.Form.Controls("Label1")
Dim btn As WinForm.Button = e.Form.Controls("Button1")
btn.Visible = False
Dim pros As WinForm.ProgressBar = e.Form.Controls("ProgressBar1")
pros.Minimum = 1
pros.Value = 1


Dim ftp As New  FTPClient    \'定义FTP客户端
ftp.Host="*******"    \'ip地址
ftp.Account = "****"      \'用户名
ftp.Password = "****"     \'密码
ftp.RootDir = "/儿童附件/"

Dim ls = ftp.GetFileList
pros.Maximum = ls.Count + 1
msgbox(pros.Maximum)

For Each fl As String In ls
    msgbox(pros.value & fl)
    lb1.Text = "正在同步:" & fl
    Application.DoEvents
    ftp.Download(fl,ProjectPath & "RemoteFiles\\" & fl)
    pros.Value = pros.Value + 1
    Application.DoEvents
Next


btn.Visible = True