VB编一饼形计时器,描述:占大半个屏幕的饼形图,走过的时间变色。可输入时长如3分钟,则3分钟后全饼变色。
1个回答
展开全部
窗体添加以下控件:按钮command1,文本框Text1,图片框Picture1,计时器Timer1
计时器每秒画一次,文本框输入秒数
Const PI = 3.14159
Dim dblInterval As Double
Dim nCount As Long
Private Sub Command1_Click()
dblInterval = -2 * PI / Val(Text1.Text) '每次覆盖的角度
nCount = 0
Randomize
With Picture1
.FillColor = RGB(CInt(Rnd * 256), CInt(Rnd * 256), CInt(Rnd * 256))
.DrawStyle = 5
End With
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Dim dblEnd As Double
dblEnd = -0.001 + (nCount + 1) * dblInterval
If dblEnd < -2 * PI Then
dblEnd = -2 * PI
Picture1.Circle (3000, 3000), 2500, , -0.001 + nCount * dblInterval, dblEnd
Timer1.Enabled = False
MsgBox "Completed!"
Exit Sub
End If
Picture1.Circle (3000, 3000), 2500, , -0.001 + nCount * dblInterval, dblEnd
nCount = nCount + 1
End Sub
计时器每秒画一次,文本框输入秒数
Const PI = 3.14159
Dim dblInterval As Double
Dim nCount As Long
Private Sub Command1_Click()
dblInterval = -2 * PI / Val(Text1.Text) '每次覆盖的角度
nCount = 0
Randomize
With Picture1
.FillColor = RGB(CInt(Rnd * 256), CInt(Rnd * 256), CInt(Rnd * 256))
.DrawStyle = 5
End With
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Dim dblEnd As Double
dblEnd = -0.001 + (nCount + 1) * dblInterval
If dblEnd < -2 * PI Then
dblEnd = -2 * PI
Picture1.Circle (3000, 3000), 2500, , -0.001 + nCount * dblInterval, dblEnd
Timer1.Enabled = False
MsgBox "Completed!"
Exit Sub
End If
Picture1.Circle (3000, 3000), 2500, , -0.001 + nCount * dblInterval, dblEnd
nCount = nCount + 1
End Sub
追问
补充描述:一个框输入或下拉选择分钟数,点开始按钮,则开始计时。点击最大化时,全图可全屏幕显示。
damyzl给的代码执行后什么也不显示。请各位高人帮忙。给全代码。谢谢!
来自:求助得到的回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询