Neil Schulz
Neil Schulz

Reputation: 3

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.

Upvotes: 0

Views: 34

Answers (1)

JuanR
JuanR

Reputation: 7803

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
Else
    Me.BackColor = Color.Red
End if

Upvotes: 0

Related Questions