Hello, is there anything wrong with the below code? i want to blink
any of the for labels if the back color is LimeGreen.
Timer5 is enabled already and starts at form closing event of another for.
so on the timer tick i have below code.
thanks for your help

Dim time2 As Integer

    Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick

        If (time2 = 1) And Label17.BackColor = Color.LimeGreen Then
            Label17.SendToBack()
        End If

        If (time2 = 2) And Label17.BackColor = Color.LimeGreen Then
            Label17.BringToFront()
            time1 = 0
        End If


        If (time2 = 1) And Label18.BackColor = Color.LimeGreen Then
            Label18.SendToBack()

        End If

        If (time2 = 2) And Label18.BackColor = Color.LimeGreen Then
            Label18.BringToFront()

            time1 = 0
        End If

        If (time2 = 1) And Label19.BackColor = Color.LimeGreen Then
            Label19.SendToBack()
        End If

        If (time2 = 2) And Label19.BackColor = Color.LimeGreen Then
            Label19.BringToFront()
            time1 = 0
        End If

        If (time2 = 1) And Label20.BackColor = Color.LimeGreen Then
            Label20.SendToBack()
        End If

        If (time2 = 2) And Label20.BackColor = Color.LimeGreen Then
            Label20.BringToFront()
            time1 = 0
        End If



        time1 += 1



    End Sub

Recommended Answers

All 3 Replies

Use Visible property instead of Bringtofront

like

'Label17.SendToBack() - Dont use that. Use
Label17.Visible=True
'And for opposite just use
Label17.Visible=False

ok ok.. good. thanks

i think you done wrong thing in tick event , you can just check it like this

if Label17.BackColor = Color.LimeGreen then 
' your code 
end if 
' this condition always checked by the timer at its every tick event , now you can just set the interval of your timer as you want.

please if i am wrong then do tell me.

Regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.