3 Replies - 7694 Views - Last Post: 11 November 2010 - 01:06 PM Rate Topic: -----

#1 NumbLock  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-November 10

Creating a traffic light

Posted 11 November 2010 - 11:56 AM

Question:

Simulate a traffic light with three text boxes placed vertically on a form. initially, the bottom text box is solid green and the other text boxes are dark grey. when the tab key is pressed, the middle text box turns yellow and bottem box turns dark grey. next time the tab key is pressed, the top box turns red and the bottem two turn dark grey. Basically the tab key cycles through the colors.

My Problem:

First off let me say im not looking for an entire code. What im looking for is help. Im new to VB (been working on it for only a week) and im haven trouble finding a sourcecode for "tab". I named the bottem text box "Green", middle text box "yellow" and top "Red"....how do i go about finishing the code?


Public Class trafficlight

    Private Sub Green_BackColorChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Green.BackColorChanged

    End Sub

    Private Sub Yellow_TabKey(...) Handles Yellow.BackColorChanged

    End Sub

    Private Sub Red_TextChanged(...) Handles Red.BackColorChanged

    End Sub
End Class


This post has been edited by Martyr2: 11 November 2010 - 12:04 PM
Reason for edit:: Please use code tags in the future, thanks!


Is This A Good Question/Topic? 0
  • +

Replies To: Creating a traffic light

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6066
  • View blog
  • Posts: 23,526
  • Joined: 23-August 08

Re: Creating a traffic light

Posted 11 November 2010 - 12:40 PM

Control.KeyDown event
Was This Post Helpful? 0
  • +
  • -

#3 NumbLock  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-November 10

Re: Creating a traffic light

Posted 11 November 2010 - 12:43 PM

is the "keydown" command the same for using "tab"?
Was This Post Helpful? 0
  • +
  • -

#4 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: Creating a traffic light

Posted 11 November 2010 - 01:06 PM

I guess the way I look at this is that:
The Tab Key Cycles through the textboxes by default. You can set the tabstops to be in order of green (tabstop 0), yellow (tabstop 1) and red (tabstop 2) then use the GotFocus event of each of the textboxes to set the current focused textbox to it's color and set the other two to gray. Repeat this for each of the 3 textboxes setting the color and the gray accordingly.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1