Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading