vb.net 下载后VB重置进度条值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16385966/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 13:30:02 来源:igfitidea点击:
VB reset progress bar value after download
提问by Thomja
As a bit of practice I am trying to get my program to download a file via the progress bar. It downloads it fine and the progress bar follows but the problem is that after the download is complete it wont reset. This is the code for the button and the bar.
作为一点练习,我试图让我的程序通过进度条下载文件。它下载得很好,进度条会跟随,但问题是下载完成后它不会重置。这是按钮和栏的代码。
Private Sub Button1_Click_1(sender As System.Object, e As System.EventArgs) Handles Button1.Click
WC.DownloadFileAsync(New Uri("imageurlhere"), "c:\myfile.jpg")
If ProgressBar1.Value = ProgressBar1.Maximum Then
ProgressBar1.Value = ProgressBar1.Minimum
End If
End Sub
Private Sub WC_DownloadProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs) Handles WC.DownloadProgressChanged
ProgressBar1.Value = e.ProgressPercentage
End Sub
采纳答案by matzone
Try this
尝试这个
Private Sub Button1_Click_1(sender As System.Object, e As System.EventArgs) Handles Button1.Click
WC.DownloadFileAsync(New Uri("imageurlhere"), "c:\myfile.jpg")
End Sub
Private Sub WC_DownloadProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs) Handles WC.DownloadProgressChanged
ProgressBar1.Value = e.ProgressPercentage
If ProgressBar1.Value = ProgressBar1.Maximum Then
ProgressBar1.Value = ProgressBar1.Minimum
End If
End Sub

