i need to make a traffic light, where RED turns to green to yellows, then back to red...while haveing the other 2 buttons black....i got red to green working but not green to yellow
help!!!
Last edited by airtas; Jun 14th, 2004 at 09:33 AM.
Dear Airtas, I corrected your code. You have to remember that you are testing the color of lbllamp1 and it becomes Black after the first time you click your button. Then I put very similar code, under yours corrected. It use a static variable. You can choose to use what you prefer.
Good job
VB Code:
Dim thiscolor As String
thiscolor = Lbllamp1.BackColor.Name
Select Case thiscolor
Case "Red"
Lbllamp1.BackColor = System.Drawing.Color.Black
Lbllamp2.BackColor = System.Drawing.Color.Green
'after executed the above code lines, LblLamp1 will be BLACK !!! So I have to intercept also this case
I'm afraid dear Airtas, perhaps I can try to explain something if you ask me (if my english is enough!), anyway the code is only a little different from your original posted!
Looks to me like ayan solved your problem. If so, you can mark your thread "Resolved" by editing your first post.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
Anyway, airtas, as I said, my first version is the most similar I found to your original code, just to give you an easy indication. The second, I think is more useful. For a so simple problem it could not be so clear, but you can choose to make a lot of different combination of colors that not depend on the previous state of light. If something is not clear....I'm here.