12. Write a VB program to change the signal by clicking on the Change Signal button


Option Explicit
Dim Cnt As Integer
Dim ca As Integer
Private Sub cmdchange_Click()
Timer1.Enabled = False
Timer2.Enabled = True
Timer2.Interval = 1000
txtcol.BackColor = vbWhite
End Sub

Private Sub Command1_Click()
Timer1.Enabled = True
Timer1.Interval = 2000
End Sub

Private Sub Form_Load()
Cnt = 0
ca = 0

txtcol.BackColor = vbRed
txtcol.Enabled = False
End Sub

Private Sub Timer1_Timer()

Select Case Cnt
Case 0:
If Timer1.Interval = 2000 Then
txtcol.BackColor = RGB(0, 255, 0)

Cnt = 1
Else
Timer1.Interval = Timer1.Interval + 200
End If
Case 1:

If Timer1.Interval = 3000 Then
txtcol.BackColor = RGB(255, 0, 0)
Timer1.Interval = 1000
Cnt = 0
Else
Timer1.Interval = Timer1.Interval + 200
End If
End Select
End Sub

Private Sub Timer2_Timer()

Select Case ca
Case 0:
If Timer2.Interval = 1500 Then
txtcol.BackColor = vbYellow
ca = 1
Else
Timer2.Interval = Timer2.Interval + 500
End If
Case 1:

If Timer2.Interval = 2000 Then
txtcol.BackColor = RGB(255, 255, 255)
Timer2.Interval = 1000
ca = 0
Else
Timer2.Interval = Timer2.Interval + 500
End If
End Select
End Sub

One thought on “12. Write a VB program to change the signal by clicking on the Change Signal button

  1. sai says:

    good stuff for vb learners

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s