Traffic lights in vb6 resolved

time2change Messages postés 60 Statut Membre -  
time2change Messages postés 60 Statut Membre -
hi. i'm tryin to make a traffic lights in vb6, but my code is not workin, plz i need some help to know my mistakes.
i have 3 timers, 1 commandbutton, 3 shapes with the 3 colors(red, yellow & green).
this is my code:
Private Sub Command1_Click()
If Command1 = True Then
Shape1.Visible = True
Timer1.Enabled = True
End If
End Sub

Private Sub Timer1_Timer()
If Interval = 0 Then
Shape1.Visible = False
Timer2.Enabled = True
Shape2.Visible = True
End If
End Sub

Private Sub Timer2_Timer()
If Interval = 0 Then
Shape2.Visible = False
Timer3.Enabled = True
Shape3.Visible = True
End If
End Sub

Private Sub Timer3_Timer()
If Interval = 0 Then
Shape3.Visible = False
Timer1.Enabled = True
Shape1.Visible = True
End If
End Sub

merci d'avance.

10 réponses

  1. Polux31 Messages postés 7219 Statut Membre 1 204
     
    Hi,

    I'm not sure that it's what you want:

    Private Sub Command1_Click()
        Shape1.Visible = False
        Timer1.Enabled = True
    End Sub
    
    Private Sub Form_Load()
        Timer1.Interval = 1000
        Timer2.Interval = 1000
        Timer3.Interval = 1000
        Shape1.Visible = False
        Shape2.Visible = False
        Shape3.Visible = False
    End Sub
    
    Private Sub Timer1_Timer()
        Shape1.Visible = True
        Shape3.Visible = False
        Timer2.Enabled = True
        Shape2.Visible = False
        Timer1.Enabled = False
    End Sub
    
    Private Sub Timer2_Timer()
        Shape2.Visible = True
        Shape1.Visible = False
        Timer3.Enabled = True
        Shape3.Visible = False
        Timer2.Enabled = False
    End Sub
    
    Private Sub Timer3_Timer()
        Shape3.Visible = True
        Shape2.Visible = False
        Timer1.Enabled = True
        Shape1.Visible = False
        Timer3.Enabled = False
    End Sub
    


    ;o)
    0
  2. time2change Messages postés 60 Statut Membre
     
    tht's exactly wht i tried few minuts ago.
    thx for the answer.
    0
    1. Polux31 Messages postés 7219 Statut Membre 1 204
       
      It's nothing, good continuation.

      Put the topic resolved, please.

      ;o)
      0
  3. time2change Messages postés 60 Statut Membre
     
    ps: enabled=false for all the timers & visible=false for all the shapes.

    Private Sub Command1_Click()
    If Command1 = True Then
    Shape1.Visible = True
    Timer1.Enabled = True
    End If
    End Sub

    Private Sub Timer1_Timer()
    If Interval = 0 Then
    Timer1.Enabled = False
    Shape1.Visible = False
    Shape3.Visible = False
    Timer2.Enabled = True
    Shape2.Visible = True
    End If
    End Sub

    Private Sub Timer2_Timer()
    If Interval = 0 Then
    Timer2.Enabled = False
    Shape1.Visible = False
    Shape2.Visible = False
    Timer3.Enabled = True
    Shape3.Visible = True
    End If
    End Sub

    Private Sub Timer3_Timer()
    If Interval = 0 Then
    Timer3.Enabled = False
    Shape3.Visible = False
    Shape2.Visible = False
    Timer1.Enabled = True
    Shape1.Visible = True
    End If
    End Sub
    0
  4. Polux31 Messages postés 7219 Statut Membre 1 204
     
    The interval specifies the frequency of excécution a code. For one second > Interval = 1000. For 5 seconds> Interval = 5000 ...
    If the interval is zero, nothing happens
    0
  5. Vous n’avez pas trouvé la réponse que vous recherchez ?

    Posez votre question
  6. time2change Messages postés 60 Statut Membre
     
    yeah ur right.
    i wanted to regist my work as .exe but this option is disactivated cuz i only have vb portable. any suggestions ??
    0
    1. Polux31 Messages postés 7219 Statut Membre 1 204
       
      Sorry, I don't know .. must be compiled before creating .exe
      0
  7. time2change Messages postés 60 Statut Membre
     
    i'm sorry but compiled to wht?? i have no idea wht ur talkin abt, i told u i just started vb6 so i rono wht i suppose to do to creat .exe
    0
  8. Polux31 Messages postés 7219 Statut Membre 1 204
     
    Please don't use abbreviations. I don't understand everything you write. My English is not very good. I'm sorry.
    It must first save the project before making an exe.
    0
  9. time2change Messages postés 60 Statut Membre
     
    sorry i didn't know.
    i said that i'm not that good with vb6, so i dont know how to creat .exe
    tell me what i should do to make it .exe plz, because i never tried it before ??
    0
  10. Polux31 Messages postés 7219 Statut Membre 1 204
     
    I have a French version of VB6. It must first save the file and after creating the Excecutive.
    I do like that:
    Menu> File> Create Projet1.exe
    0
  11. time2change Messages postés 60 Statut Membre
     
    ok merci, mé le prob c ke g seulement un vb portable, é l'option projet1.exe é désactivée. de toute façon j v éssayer de telecharger vb6 complet car j l'avais just trouvé. merci encore de ton aide.
    0