Foxtable(狐表)用户栏目专家坐堂 → [求助] 窗口进度条不动态显示??


  共有1751人关注过本帖树形打印复制链接

主题:[求助] 窗口进度条不动态显示??

帅哥哟,离线,有人找我吗?
lmlptj
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:455 积分:3756 威望:0 精华:0 注册:2012/2/8 14:19:00
[求助] 窗口进度条不动态显示??  发帖心情 Post By: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

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By: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
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:455 积分:3756 威望:0 精华:0 注册:2012/2/8 14:19:00
  发帖心情 Post By:2018/1/4 10:23:00 [只看该作者]

仍依旧呢图片点击可在新窗口打开查看

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By: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


 回到顶部