我有两个在Visual Studio中运行的计时器,其中一个工作正常,但是当它在运行时按任意键时其他计时器停止,如果我没有按任何键,它工作正常。对不起,如果这个XD的代码很乱。
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
If PictureBox2.Top = 277 Then
Label3.Text = "Label3"
End If
If e.KeyCode = Keys.W And Label3.Text = "Label3" Or Label3.Text = "single" And e.KeyCode = Keys.W Then
PictureBox2.Top = PictureBox2.Top - 64
End If
If PictureBox2.Top = 213 Then
Label3.Text = "single"
End If
If e.KeyCode = Keys.W Then
Label1.Text = "0"
End If
If Label1.Text = "0" And Label3.Text = "single" Then
Label2.Text = "0"
End If
If e.KeyCode = Keys.W Then
Timer1.Enabled = True
End If
If PictureBox2.Top = 149 Then
Label3.Text = "double"
End If
If Label3.Text = "double" Then
Timer2.Enabled = True And Label2.Text = "0"
End If
End Sub
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Label1.Text = Label1.Text + 1
If Label1.Text = "30" Then
Timer1.Enabled = False
End If
If Timer1.Enabled = False And Label3.Text = "single" Then
PictureBox2.Top = PictureBox2.Top + 64
End If
End Sub
Friend WithEvents Label1 As System.Windows.Forms.Label
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Timer2 As System.Windows.Forms.Timer
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
Label2.Text = Label2.Text + 1
If Label3.Text = "double" Then
Timer2.Enabled = True
End If
If Label2.Text = "30" Then
Timer2.Enabled = False
End If
If Timer2.Enabled = False And Label3.Text = "double" Then
PictureBox2.Top = PictureBox2.Top + 128
End If
End Sub
答案 0 :(得分:1)
我不是一个vb.net人,因此我可以完全脱离基础并为它投票,但这一行看起来不对:
True and Label2.Text = "0"
用一种理智的语言,将被视为:
将Time2.Enabled设置为右侧值,(True and [Anything]
)
[Anything]
逻辑Timer2.Enabled
...假设Label2.Text不是“0”,因此将query.setQuery("select A, sum(C) group by A ");
设置为false,这可能不是您想要的
此代码可能存在其他问题,但我会从那个问题开始。