Results 1 to 2 of 2

Thread: Timer Problem

  1. #1
    konnosgar is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Apr 2012
    Posts
    1
    Reputation
    0

    Angry Timer Problem

    I have a button, a timer and a panel
    When i click the button timer1 starts

    timer1.start()

    timer has 3 ifs

    if panel1.backcolor = color.red
    if panel1.backcolor = color.green
    if panel1.backcolor = color.blue

    when the timer ticks both of 3 ifs runs
    IS there a way that i can set the timer ticks for only 1 if ?

  2. #2
    jmcilhinney's Avatar
    jmcilhinney is online now VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    11,504
    Reputation
    1553
    Obviously the Panel can only have one BackColor at a time so, if you find a match, why keep checking? You should not have three If statements. You should be using If...ElseIf...ElseIf. If the first one is True then the next two aren't even tested.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking