timer and loop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • niall lally
    New Member
    • Oct 2006
    • 1

    #1

    timer and loop

    hi guys,

    im a complete noob.

    basically im creating a program where i want a series of circles to appear on the screen each with a varied amount of delay.....so for example the first circle could appear after 1 second the second after .5 seconds and the third after 1.5 seconds

    code<

    Dim num As Integer

    Private Sub cmdEnd_Click()
    End

    End Sub

    Private Sub cmdStart_Click( )

    Dim x1 As Integer, x2 As Integer, y1 As Integer, y2 As Integer
    Dim c1 As Integer, c2 As Integer, c3 As Integer, r As Integer
    picOutput.Cls

    Timer1.Interval = Int(Rnd * 2000)
    Timer1.Enabled = True


    End Sub

    Private Sub Timer1_Timer()

    num = num + 1

    x1 = Int(Rnd * 140)
    y1 = Int(Rnd * 140)
    r = 10
    c1 = Int(Rnd * 255)
    c2 = Int(Rnd * 255)
    c3 = Int(Rnd * 255)


    picOutput.Scale (-100, 200)-(200, -100)
    picOutput.FillS tyle = 0
    picOutput.PSet (x1, y1), RGB(c1, c2, c3)
    picOutput.Circl e (x1, y1), r, RGB(c1, c2, c3)
    Timer1.Enabled = False

    End Sub
    code>
  • albertw
    Contributor
    • Oct 2006
    • 267

    #2
    Originally posted by niall lally
    hi guys,

    im a complete noob.

    basically im creating a program where i want a series of circles to appear on the screen each with a varied amount of delay.....so for example the first circle could appear after 1 second the second after .5 seconds and the third after 1.5 seconds

    code<

    Dim num As Integer

    Private Sub cmdEnd_Click()
    End

    End Sub

    Private Sub cmdStart_Click( )

    Dim x1 As Integer, x2 As Integer, y1 As Integer, y2 As Integer
    Dim c1 As Integer, c2 As Integer, c3 As Integer, r As Integer
    picOutput.Cls

    Timer1.Interval = Int(Rnd * 2000)
    Timer1.Enabled = True


    End Sub

    Private Sub Timer1_Timer()

    num = num + 1

    x1 = Int(Rnd * 140)
    y1 = Int(Rnd * 140)
    r = 10
    c1 = Int(Rnd * 255)
    c2 = Int(Rnd * 255)
    c3 = Int(Rnd * 255)


    picOutput.Scale (-100, 200)-(200, -100)
    picOutput.FillS tyle = 0
    picOutput.PSet (x1, y1), RGB(c1, c2, c3)
    picOutput.Circl e (x1, y1), r, RGB(c1, c2, c3)
    Timer1.Enabled = False

    End Sub
    code>
    this way you need to press the cmdStart button every time while you have timer disabled after drawing.
    you may also include a new timer interval instead of timer1.enabled= false., where the program continues drawing circles.

    Comment

    Working...