问题描述
我使用的代码如下:
My.Computer.FileSystem.CopyFile(
Software\Service Packs \WindowsXP\SP2\WindowsXP-KB835935-SP2-ENU.exe,
C:\Service Pack\WindowsXP-KB835935-SP2-ENU.exe)
Process.Start(C:\Service Pack\WindowsXP-KB835935-SP2-ENU.exe)
这只是将Windows XP Service Pack从pendrive复制到上面的C驱动器。
我希望在表单中添加一个进度条,
在 Timer1_Tick
下添加以下代码:
代码示例
私有子Timer1_Tick()处理Timer1.Tick
ProgressBar1.Increment(20)
如果ProgressBar1.Value = ProgressBar1.Maximum然后
Timer1.Stop
'当进度条达到最大值时在这里添加要做的事。
End If
End Sub
Private Sub Form1_Load()处理Mybase.Load
Timer1.Stop
End Sub
Private Sub Button1_Click()Handles Button1.Click
Timer1.Start
End Sub
说明
ProgressBar1.Increment
中指定的值表示增加的百分比。
语句 Timer1.Start
必须添加到事件中您要触发 ProgressBar
(不必在 Form_Load
事件下写入)。
希望它能正常工作。
I am using this code:
My.Computer.FileSystem.CopyFile(
"Software\Service Packs\WindowsXP\SP2\WindowsXP-KB835935-SP2-ENU.exe",
"C:\Service Pack\WindowsXP-KB835935-SP2-ENU.exe")
Process.Start("C:\Service Pack\WindowsXP-KB835935-SP2-ENU.exe")
This simply copies Windows XP Service Pack from a pendrive to the C Drive located above.
I wish to add a Progress bar to the Form and need the code in order to do this.
Thank you,
Drag a ProgressBar and Timer to the form.
Add the following code under Timer1_Tick
event:
Code And Example
Private Sub Timer1_Tick () Handles Timer1.Tick
ProgressBar1.Increment (20)
If ProgressBar1.Value = ProgressBar1.Maximum then
Timer1.Stop
'Add things here you want to do when progressbar reaches maximum.
End If
End Sub
Private Sub Form1_Load () Handles Mybase.Load
Timer1.Stop
End Sub
Private Sub Button1_Click () Handles Button1.Click
Timer1.Start
End Sub
Explanation
The value specified in the ProgressBar1.Increment
means the percentage of increase. It will stop increasing when the value is maximum.
The Statement Timer1.Start
must be added to the event from which you want to trigger the ProgressBar
(Not necessary to write under the Form_Load
event).
Hope it works perfectly.
这篇关于将进度栏从简单副本添加到C驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!