VB6 Delay Function?

Discussion in 'Programming' started by ash1ey82, Jan 13, 2014.

  1. #1
    Is their anyway to delay a function on VB6? I tried to stop the thread but that didn't too well, the program crashed. It is outputting to a model car and I need it to flash but how do I set an interval between the flashes?
     
    ash1ey82, Jan 13, 2014 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    Use the sleep method.
     
    ThePHPMaster, Jan 13, 2014 IP
  3. ash1ey82

    ash1ey82 Active Member

    Messages:
    588
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    88
    #3
    @ThePHPMaster the sleep method is messed up, kept on crashing VB. I just decided to use a bunch of complex timers, but if anyone has a better solution please do post it.
     
    ash1ey82, Jan 14, 2014 IP
  4. MaxWebTraffic

    MaxWebTraffic Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #4
    I wrote this in vb.net but I think it can be easily converted in VB6 ;)

    Public Sub my_Pause(ByVal my_Seconds As Integer)
    Dim t_Start As Date = Date.Now

    Do Until t_Start.AddSeconds(my_Seconds) < Date.Now
    Application.DoEvents()
    Loop
    End Sub
     
    MaxWebTraffic, Feb 3, 2014 IP
  5. ash1ey82

    ash1ey82 Active Member

    Messages:
    588
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    88
    #5
    I managed to get it to work with an if statement an integer within a timer.
     
    ash1ey82, Feb 6, 2014 IP