|登录 |注册

查看: 2231|回复: 7
打印 上一主题 下一主题

Progressbar 与 button 的问题

[复制链接]
maple迷
2010-4-3 02:52 PM

  1. Public Class Form1

  2.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  3.         For i As Integer = 90 To 100
  4.             If ProgressBar1.Value = i Then
  5.                 Label2.Text = Label2.Text + 1
  6.             End If
  7.         Next
  8.     End Sub

  9.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  10.         ProgressBar1.Value = ProgressBar1.Value + 1
  11.     End Sub
  12. End Class
复制代码
我是想
progressbar1 的 value 从 90 到 100 之间按下 button1 的话 , label2 的 text 就会 + 1
不是的话就 label4 的 text +1
不过 code 到这 2 行就试试 debug 结果有错误
progressbar1 的 value 貌似到 98 - 99 时跳回 VB 界面

请各位大人指教
goodhermit95
2010-4-3 03:11 PM
回复 1# maple迷


    ...你的Timer到100要停 不然會出現exception
不是的話就level4.text + 1,你沒code進去
maple迷
2010-4-3 07:04 PM
你是说

if progressbar1.value = "100" then
timer1.enabled = false

??
goodhermit95
2010-4-3 11:40 PM
回复 3# maple迷


    你自己debug不是比我回复你来得快吗
maple迷
2010-4-3 11:47 PM
能用了
不过

if progressbar1.value = "100" then
progressbar1.value = "0"

以上想做成 reset 作用
不过这个 code 导致
progressbar1 的 value 走到
目测 80% 的位置就 reset 了
是什么问题呢?
goodhermit95
2010-4-4 01:57 PM
回复 5# maple迷


    ...邏輯點,如果你要不會有這個問題的話應該是再progressbar.value = 100的時候close掉timer而不是等於0 這樣的話會一直重複
zechs
2010-4-5 07:08 PM
你的progressbar maximum是多少?

# For i As Integer = 90 To 100
#             If ProgressBar1.Value = i Then
#                 Label2.Text = Label2.Text + 1
#             End If
#         Next

这段改成
if progressbar.value >= 90 and <=100 then
     Label2.Text = Label2.Text + 1
endif
会不会比较好一点?
tjrong
2010-4-14 02:07 AM
你的timer 一直在跑 so error
您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2026-1-1 10:08 AM , Processed in 0.098336 second(s), 24 queries .

Powered by Discuz! X2.5 © 2001-2012 Comsenz Inc.

本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved

Dedicated Server powered by iCore Technology Sdn. Bhd.

合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部