-- 作者:pcxjxjhkw
-- 发布时间:2014/10/6 15:04:00
-- [求助]进度条问题
下面这段代码中,进度条不能正常显示,麻烦老师们审查一下,是什么地方出错了,谢谢
With Tables("信访办理_附件表") If .ShowCheckBox = False Then \'单个下载 If .Current IsNot Nothing Then Dim wj As String = .Current("路径及文件名") Dim Ifo As new FileInfo(wj) If FileSys.FileExists(wj) = True \'检查文件是否存在 Dim dlg As New SaveFileDialog \'定义一个新的SaveFileDialog dlg.FileName = Ifo.Name dlg.Title = "文件下载..." dlg.OverwritePrompt =True \'dlg.InitialDirectory = SpecialFolder.MyDocuments If dlg.FileName = wj Then dlg.InitialDirectory = SpecialFolder.MyDocuments \'最初显示的目录为我的文档 End If If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 If dlg.FileName <> wj Then \'不能保存于当前目录 FileSys.CopyFile(wj,dlg.FileName,True) .Current("下载次数") = .Current("下载次数") + 1 .Current("最近下载人") = _UserName .Current("最近下载时间") = Date.Now Dim lst As new List(of String) lst = .Current.DataRow.Lines("下载情况") If .Current("下载情况") = Nothing Then lst.Add("序号 下载时间 下载人 计算机名") lst.Add(.Current("下载次数") & " " & Date.Now & " " & _UserName & " " & SysInfo.ComputerName) Else lst.Add(.Current("下载次数") & " " & Date.Now & " " & _UserName & " " & SysInfo.ComputerName) End If .Current.DataRow.Lines("下载情况") = lst .save() If MessageBox.Show("文件下载成功,是否打开?","温馨提示",MessageBoxButtons.YesNo,MessageBoxIcon.Warning)=DialogResult.Yes Then Dim Proc As New Process \'打开文件 Proc.File = dlg.FileName Proc.Start() End If End If End If Else MessageBox.Show("下载失败!该文件已不存在,可能已被删除!","温馨提示",MessageBoxButtons.OK,MessageBoxIcon.Error) End If End If Else \'批量下载 If .GetCheckedRows.count = 0 Then MessageBox.Show("错误!未选择要下载的附件,请勾选!.","温馨提示",MessageBoxButtons.OK,MessageBoxIcon.Warning) Return Else Dim dlg As New FolderBrowserDialog \'定义一个新选择目录对话框 dlg.Description = "请选择批量下载文件的路径..." \'对话框说明信息 dlg.ShowNewFolderButton = True \'显示新建文件夹按钮 If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 Dim s As Integer = 0 \'记录成功下载文件的个数 \'显示进度条 Forms("进度").Show \'打开进度窗口 Dim pb As WinForm.ProgressBar = Forms("进度").Controls("进度条") Dim xx As WinForm.Label = Forms("进度").Controls("信息") Dim xx1 As WinForm.Label = Forms("进度").Controls("信息1") Dim jd As WinForm.Label = Forms("进度").Controls("进度") xx1.Text = "下载附件,请稍等..." xx.text = "正在下载:" pb.Minimum = 0 pb.Maximum = .GetCheckedRows.count pb.Value = 0 jd.text = "0%" \'====================== For I As Integer = 1 To .GetCheckedRows.count Dim r As Row = .GetCheckedRows(i-1) Dim wj As String = r("路径及文件名") Dim Ifo As new FileInfo(wj) \'文件信息 xx.text = "正在下载: " & Ifo.Name If FileSys.FileExists(wj) = True \'检查文件是否存在,只有该文件存在才下载复制 FileSys.CopyFile(wj,dlg.SelectedPath & "\\" & Ifo.Name ,True) \'复制文件 s = s + 1 \'更新下载信息 r("下载次数") = r("下载次数") + 1 r("最近下载人") = _UserName r("最近下载时间") = Date.Now Dim lst As new List(of String) lst = r.DataRow.Lines("下载情况") If r("下载情况") = Nothing Then lst.Add("序号 下载时间 下载人 计算机名") lst.Add( r("下载次数") & " " & Date.Now & " " & _UserName & " " & SysInfo.ComputerName) Else lst.Add( r("下载次数") & " " & Date.Now & " " & _UserName & " " & SysInfo.ComputerName) End If r.DataRow.Lines("下载情况") = lst End If pb.Value = i jd.text = Round2(pb.Value/pb.Maximum*100,1) & "%" Next .save() Forms("进度").Close \'关闭进度窗口 If MessageBox.Show("成功下载 " & s & " 个文件.现在是否打开目录,请确认?","温馨提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.Yes Then Dim Proc As New Process \'打开目录 Proc.File = dlg.SelectedPath Proc.Start() End If End If End If End If End With
|