Traffic Light Program in VB6

Traffic Light is a road signal for directing vehicular traffic by means of colored lights, typically red for stop, green for go, and yellow for proceed with caution. Also called stoplight, traffic signal. In this tutorial, we will make a Traffic Light Program with the use only of shapes and timer. Now, let's start this tutorial! 1. Let's start this tutorial by following the following steps in Microsoft Visual Basic 6.0: Open Microsoft Visual Basic 6.0, click Choose Standard EXE, and click Open. 2. Next, add Three Shapes named as Shape1 with fillcolor of &H00004000&, Shape2 with fillcolor of &H00000080&, and Shape3 with fillcolor of &H0000C0C0&.Be sure that all of the shapes are having a fillstyle of 0-solid. Add also a timer named Timer1 and have an Interval of 3000 means a 3-second interval. You must design your interface like this: design 3. Put this code in your code module.
  1. Private Sub Form_Load()
  2. Timer1.Enabled = True
  3. Shape1.Visible = True
  4. Shape2.Visible = False
  5. Shape3.Visible = False
  6.  
  7. End Sub
  8. Private Sub Timer1_Timer()
  9. If Shape1.Visible Then
  10.  
  11. Shape2.Visible = True
  12. Shape1.Visible = False
  13. Shape3.Visible = False
  14.  
  15. ElseIf Shape2.Visible Then
  16.  
  17. Shape3.Visible = True
  18. Shape2.Visible = False
  19. Shape1.Visible = False
  20.  
  21. Else
  22.  
  23. Shape1.Visible = True
  24. Shape2.Visible = False
  25. Shape3.Visible = False
  26.  
  27. End If
  28.  
  29. End Sub
We have created an event of the Timer for Timer1. We have created an If-Else statement that Shape1 is visible then only Shape2 will be the visible out of the three shapes. Shapes provides a base class for shape elements, such as the Ellipse, Polygon, and Rectangle objects. Timer.visible overrides the Visible property of the Control class to prevent this value from being set. If Shape2 is visible then only Shape3 will be the visible out of the three shapes.Otherwise, Shape1 will be visible if Shape3 is visible when the timer is ticking. In the form_load, we have created to enabled the time and displayed first the shape1 as Green color or 'Go'. Timer.Enabled gets or sets a value that indicates whether the Timer control initiates a postback to the server after the number of milliseconds specified in the Interval property has elapsed.

Output:

For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below. Best Regards, Engr. Lyndon Bermoy IT Instructor/System Developer/Android Developer/Freelance Programmer Mobile: 09488225971 Landline: 826-9296 E-mail:[email protected] Add and Follow me on Facebook: https://www.facebook.com/donzzsky Visit and like my page on Facebook at: https://www.facebook.com/BermzISware

Add new comment