vb.net 使用visual basic上的按钮增加进度条?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23861713/
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
Increment a progress bar with button on visual basic?
提问by xtremec0r3
I need to increment a progress bar 1% every time the i click a button and a radio button is check it...? How can i make that.. im learning Visual Basic.. Thanks!
每次我单击一个按钮和一个单选按钮时,我都需要将进度条增加 1%...?我怎样才能做到……我正在学习 Visual Basic ……谢谢!
Public Class Form1
公开课表1
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
ProgressBar1.Increment(+1)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If RadioButton1.Checked = True Then
End If
End Sub
End Class
结束班
回答by ViSTA
You don't need to use the timer for this.
您不需要为此使用计时器。
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If RadioButton1.Checked = True Then
dim x as integer= ProgressBar1.value
x += 1
ProgressBar1.value = x
End If
End Sub
回答by Rynoh97
You could do something a lot simpler.
你可以做一些更简单的事情。
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ProgressBar1.PerformStep()
End Sub
PerformStepmoves the bar up one increment. The step in based upon your increment. To change it, change the Stepin the properties. It is 10 by default. For more goodies go toherefor all progress bar fun.
PerformStep将条向上移动一个增量。基于您的增量的步骤。要更改它,请更改Step属性中的 。默认为 10。欲了解更多好东西,请到这里享受所有进度条的乐趣。
回答by Creator
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Private Sub Button1_Click(sender As Object, e As EventArgs) 处理Button1.Click
If RadioButton1.Checked = True Then
Timer1.Enabled = True
Timer1.Interval = 100 '1000 is 1 sec
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
ProgressBar1.Increment(+1)
If ProgressBar1.Value = 100 Then
Timer1.Enabled = False
End If
End Sub

