Visual Basic: Factoring Time in Light Alternation

  • Thread starter nick227
  • Start date
  • Tags
    Visual
In summary, the person is working on a program to light LEDs from the parallel port of their computer and wants to alternate the lights between three colors. They are new to VB and programming in general and are wondering if there is a way to factor time into the alternating lights process. They ask if there is a way to run one set of lights for a specific amount of time before moving on to the next set. They also inquire about doing this with Java and having messages appear for a certain amount of time. They are advised to use the VB Timer control and Time functions in Java to achieve this.
  • #1
nick227
36
0
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 let's 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?
 
Technology news on Phys.org
  • #2
nick227 said:
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 let's 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?
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.)
 
  • #3


I can tell you that what you are looking for is called "time-based programming". This is a common concept in computer programming, where the sequence of events is controlled by time. In Visual Basic, you can use the "Timer" control to create timed events. You can set the interval for the timer and then write code to control what happens when the timer reaches that interval. This can be used to control the alternating lights in your program.

In terms of displaying messages for a specific amount of time, this can also be achieved using time-based programming. In VB, you can use a similar approach with the "Timer" control to control when the message appears and disappears. In Java, you can use the "Timer" class to schedule tasks to be executed at specific intervals. Both languages have similar capabilities when it comes to time-based programming.

It's great that you're exploring different ways to enhance your program. Time-based programming is a useful skill to have in your programming toolkit and can be applied in many different applications. Good luck with your project!
 

Related to Visual Basic: Factoring Time in Light Alternation

1. What is Visual Basic?

Visual Basic is a programming language developed by Microsoft that is used to create applications for Windows operating systems. It is a high-level and event-driven language that is designed to be user-friendly and easy to learn.

2. What is "Factoring Time in Light Alternation" in Visual Basic?

"Factoring Time in Light Alternation" is a concept in Visual Basic that refers to the ability to control the timing of events and actions within a program. This allows for more precise control over the flow of a program and can be useful for animations, game development, and other time-sensitive applications.

3. How do you factor time in light alternation in Visual Basic?

In Visual Basic, you can factor time in light alternation by using the Timer control. This control allows you to set a specific interval at which an event or action will occur. You can also use the DoEvents function to pause the execution of code for a specific amount of time.

4. Why is factoring time in light alternation important in Visual Basic?

Factoring time in light alternation is important in Visual Basic because it allows for more control and precision in programming. It can help create smoother animations, synchronize actions in a game, and improve the overall user experience.

5. What are some tips for effectively factoring time in light alternation in Visual Basic?

Some tips for effectively factoring time in light alternation in Visual Basic include using the Timer control instead of a loop to avoid freezing the program, using multiple timers for different actions, and using the DoEvents function sparingly to prevent performance issues.

Similar threads

  • Programming and Computer Science
Replies
4
Views
511
  • Programming and Computer Science
Replies
2
Views
469
  • Programming and Computer Science
Replies
1
Views
703
  • Programming and Computer Science
Replies
3
Views
721
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
Replies
5
Views
888
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
10
Views
3K
  • Electrical Engineering
Replies
26
Views
2K
  • Programming and Computer Science
2
Replies
50
Views
4K
Back
Top