Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Visual basic question

  1. Mar 19, 2008 #1
    Hey all. I am working on this program that will light LEDs from the parallel port of my computer. I think i have everything all set, but i want to do something cool. I was thinking of alternating lights between three colors. i am new to VB (and programming in general) and was wondering if there was a way to factor time into alternating the lights. Can i somehow make a method or some sort of loop that lets me run one set of lights for say 5 seconds or any amount of time then move on to the next set of lights? Basically, how do i factor in time?

    Also, if i can do this with VB, can i do it with java? say i want to have a message appear for 10 seconds, then disappear and have another message appear for 10 seconds?
  2. jcsd
  3. Mar 19, 2008 #2


    User Avatar
    Gold Member

    Certainly. Look at the VB Timer control. You drag it onto your page and set its properties (look at the interval property) and turn it on and it will fire each interval.

    In Java, you won't have it all wrapped up in a control, but you will have access to Time functions. You'd store the current Time, and test it using a loop. When the old and current time are the appropraite number apart, you trigger your action. (You can do it the same way in VB too.)
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook