• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Ultimate VB noob

matas

Golden Member
so here I am, trying to learn first programming language lol. I have to make this program that I find rather difficult. I have to make a traffic light with three vertical picture boxes that change colors when tab is pressed down. There are 3 picture boxes, and only one color must show at the time, starting with green. When you press tab, green supposed to turn white, and yellow picture box supposed to turn yellow, and when tab is pressed again, yellow should turn white and red picture box turn red. And it should cycle like that. How do I bind Tab key?
 
Private Sub Form1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyTab Then
# Color changing logic
End If
End Sub

EDIT: Wow I haven't touched VB6 in years. I'm surprised I remembered that...
 
It does not seem to respond when I press Tab. I figured out that GotFocus works when tab is pressed down. But I'm not sure how to make this changing sequence to work.
 

IIRC you have to set the form property KeyPreview = True on your form in the designer so the keypress event happens..
 
I need help now with sub procedures. Program that adds three numbers from three text boxes and averages them out. I know how to do it regularly but I'm not sure how to do a sub procedure and not sure what does that 'call' mean. Any help?
 
Back
Top