我正在制作一个百万富翁的应用程序,我希望每次回答正确的问题时按钮的背景颜色都会闪烁
答案 0 :(得分:0)
哪里有你的代码来确定正确的答案......
If answer = "Correct" Then
Timer.Enabled = True
End If
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If Button1.BackColor = Color.Red Then
Button1.BackColor = Color.LightGray
Else
Button1.BackColor = Color.Red
End If
If Button1.BackColor = Color.LightGray Then
Timer1.Enabled = False
End If
End Sub
答案 1 :(得分:0)
If answer = "Correct" Then
Timer.Enabled = True
End If
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If Button1.BackColor = Color.Red Then
Button1.BackColor = Color.LightGray
Else
Button1.BackColor = Color.Red
End If
If Button1.BackColor = Color.LightGray Then
Timer1.Enabled = False
End If
End Sub
我认为应该可以
答案 2 :(得分:0)
如果您希望按钮永久闪烁,或者想要比闪烁更生动的东西怎么办?
动画GIF图像和WAV声音非常简洁。它们可以在任何接受图像的控件中工作。
从网上下载“ Celebration” GIF文件或创建一个。 从网上下载“ Celebration” WAV文件或创建一个。
Button1.Image = Image.FromFile("YourHappyDance.gif")
My.Computer.Audio.Play("YourHappySong.wav", AudioPlayMode.WaitToComplete)
Button1.image = Nothing
在AudioPlayMode设置为WaitToComplete的情况下,第3行直到声音/歌曲结束后才执行。因此,延迟。您可以将3号线放在一个循环中以增加延迟。
答案 3 :(得分:0)
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Timer1.Start()
End Sub
// put this routine in your main form
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If Button1.BackColor = Color.Red And Timer.Enabled = True Then
Button1.BackColor = Color.LightGray
Else
Button1.BackColor = Color.Red
End If
If Button1.BackColor = Color.LightGray Then
Timer1.Enabled = False
End If
End Sub