vb中如何让一个图形控件变换颜色,就是点一下按钮变换一下,再点一下又变回来交替,然后另一个就是让它闪
vb中如何让一个图形控件变换颜色,就是点一下按钮变换一下颜色,再点一下又变回来交替,然后另一个按钮就是让它在三个颜色中交替闪烁(能不用timer吗,当然用也可以)。谢谢了...
vb中如何让一个图形控件变换颜色,就是点一下按钮变换一下颜色,再点一下又变回来交替,然后另一个按钮就是让它在三个颜色中交替闪烁(能不用timer吗,当然用也可以)。
谢谢了 因为自己现在没有分 实在抱歉 展开
谢谢了 因为自己现在没有分 实在抱歉 展开
2个回答
展开全部
加两个 Command 和一个Picture 和一个Timer用以下代码就可以了!
Private Sub Command1_Click()
Timer1.Enabled = False
If Picture1.BackColor = &HFF& Then
Picture1.BackColor = &HFF0000
Else
Picture1.BackColor = &HFF&
End If
End Sub
Private Sub Command2_Click()
If Timer1.Enabled = False Then
Timer1.Enabled = True
Else
Timer1.Enabled = False
End If
End Sub
Private Sub Timer1_Timer()
If Picture1.BackColor = &HFF& Then
Picture1.BackColor = &HFF0000
ElseIf Picture1.BackColor = &HFF0000 Then
Picture1.BackColor = &HFF00&
Else
Picture1.BackColor = &HFF&
End If
End Sub
Private Sub Command1_Click()
Timer1.Enabled = False
If Picture1.BackColor = &HFF& Then
Picture1.BackColor = &HFF0000
Else
Picture1.BackColor = &HFF&
End If
End Sub
Private Sub Command2_Click()
If Timer1.Enabled = False Then
Timer1.Enabled = True
Else
Timer1.Enabled = False
End If
End Sub
Private Sub Timer1_Timer()
If Picture1.BackColor = &HFF& Then
Picture1.BackColor = &HFF0000
ElseIf Picture1.BackColor = &HFF0000 Then
Picture1.BackColor = &HFF00&
Else
Picture1.BackColor = &HFF&
End If
End Sub
展开全部
窗体上放个TIMER
Private Sub Command1_Click()
Static i
i = i + 1
If i Mod 2 = 1 Then
Picture1.BackColor = vbBlue
Else
Picture1.BackColor = vbRed
End If
End Sub
Private Sub Command2_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Interval = 500
Timer1.Enabled = False
Picture1.BackColor = vbRed
End Sub
Private Sub Timer1_Timer()
Static i
i = i + 1
If i Mod 3 = 0 Then
Picture1.BackColor = vbBlue
ElseIf i Mod 3 = 1 Then
Picture1.BackColor = vbGreen
Else
Picture1.BackColor = vbRed
End If
End Sub
Private Sub Command1_Click()
Static i
i = i + 1
If i Mod 2 = 1 Then
Picture1.BackColor = vbBlue
Else
Picture1.BackColor = vbRed
End If
End Sub
Private Sub Command2_Click()
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Interval = 500
Timer1.Enabled = False
Picture1.BackColor = vbRed
End Sub
Private Sub Timer1_Timer()
Static i
i = i + 1
If i Mod 3 = 0 Then
Picture1.BackColor = vbBlue
ElseIf i Mod 3 = 1 Then
Picture1.BackColor = vbGreen
Else
Picture1.BackColor = vbRed
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询