PDA

View Full Version : استفاده صحیح از تایمر



پرستو پارسایی
جمعه 16 آبان 1393, 17:11 عصر
با سلام
من برای کار با تایمر و لیبل از این کدها استفاده کردم ولی هنگامیگه روی پیکچرباکس ها کلیک میکنم گاها visible لیبل ها رو حالت false قرار میگیره نمونه مشکلم رو تو یک سورس کوچک ارسال کردم
ممنون میشم در صورت اطلاع پاسخ دهید

Public Class Form1



Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick


If txtNumber.Text = "1" Then
LBL1.Visible = Not (LBL1.Visible)
Else
If txtNumber.Text = "2" Then
LBL2.Visible = Not (LBL2.Visible)
Else
If txtNumber.Text = "3" Then
LBL3.Visible = Not (LBL3.Visible)
End If
End If
End If




End Sub


Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
txtNumber.Text = 1
End Sub


Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
txtNumber.Text = 2
End Sub


Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
txtNumber.Text = 3
End Sub
End Class

ghaem-soft
جمعه 16 آبان 1393, 18:49 عصر
از این کد استفاده کنید






Public Class Form1


Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

If txtNumber.Text = "1" Then
LBL1.Visible = Not (LBL1.Visible)
Else
If txtNumber.Text = "2" Then
LBL2.Visible = Not (LBL2.Visible)
Else
If txtNumber.Text = "3" Then
LBL3.Visible = Not (LBL3.Visible)
End If
End If
End If


End Sub

Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
txtNumber.Text = 1
LBL1.Visible = True
LBL2.Visible = True
LBL3.Visible = True
End Sub

Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
txtNumber.Text = 2
LBL1.Visible = True
LBL2.Visible = True
LBL3.Visible = True
End Sub

Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
txtNumber.Text = 3
LBL1.Visible = True
LBL2.Visible = True
LBL3.Visible = True
End Sub
End Class