问题
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,
回答1:
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.
来源:https://stackoverflow.com/questions/22029857/adding-a-progress-bar-from-a-simple-copy-to-the-c-drive