How to Loop though BackColor change?


absolute noob to coding here.

I’m trying to setup a form that opens from an action or a button click that loops through 2 colors with a timer

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

    Me.BackColor = Color.FromArgb(255, 255, 255)

I’ve set the background color to red and I want it to flicker between red and white like an alarm.

Any help is much appreciated!

Tried using Do while Loop but it doesn’t seem to work
or at least I don’t understand the statement enough.

>Solution :

You are close.

Throw a Timer component into the form and configure it through the properties editor:

  • Enabled = true.
  • Interval to that of your choice (how long between color changes).

Then use the following in the Tick event:

If Me.BackColor = Color.Red Then
    Me.BackColor = Color.White
    Me.BackColor = Color.Red
End if

Leave a Reply Cancel reply