首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

点击按钮后,5秒时间后,ProgressBar走到一半,该如何写呢

2012-03-03 
点击按钮后,5秒时间后,ProgressBar走到一半,该怎么写呢?找了很多答案,没找到确切的,请各位给我个代码哈,谢

点击按钮后,5秒时间后,ProgressBar走到一半,该怎么写呢?
找了很多答案,没找到确切的,请各位给我个代码哈,谢谢啦

[解决办法]
不知道这样行不:

VB code
Option ExplicitPrivate Sub Command1_Click()    Timer1.Enabled = True    ' .......   '其它代码End SubPrivate Sub Form_Load()    Timer1.Enabled = False    Timer1.Interval = 5000End SubPrivate Sub Timer1_Timer()    Timer1.Enabled = False    ProgressBar1.Value = (ProgressBar1.Max + ProgressBar1.Min) / 2    DoEventsEnd Sub
[解决办法]
'添加 Timer1 Command1 Progressbar1

Private Declare Function GetTickCount& Lib "kernel32" ()
Dim StartTm&, kk&, PerCent%
Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = False
ProgressBar1.Min = 0
ProgressBar1.Max = 10
End Sub

Private Sub Command1_Click()
StartTm = GetTickCount
ProgressBar1.Value = 0
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
kk = Int((GetTickCount - StartTm) \ 1000)
ProgressBar1.Value = kk
PerCent = Int(kk / ProgressBar1.Max * 100)
Me.Cls: Print Str(PerCent) & "%"
If PerCent >= 100 Then
Timer1.Enabled = False
MsgBox "满啦"
End If
End Sub

[解决办法]
for ...next 里面加个 Doevents试看

热点排行