Results 1 to 4 of 4

Thread: whats wrong with this code?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2002
    Posts
    4

    Angry whats wrong with this code?

    i have this code -
    Option Explicit
    Dim jump As Integer
    Dim xPos As Integer

    Private Sub MoveButton()
    xPos = Int((3400) * Rnd) \ 480
    img1.Left = 120 + xPos * 480
    End Sub

    Private Sub cmd1_Click()
    Timer1.Interval = 400
    Randomize
    lblEnd.Caption = ""
    End Sub


    Private Sub Timer1_Timer()
    Call MoveButton
    jump = jump + 1
    If jump = 20 Then Call endgame

    End Sub

    Private Sub endgame()
    Timer1.Interval = 0
    lblEnd = Label1(xPos).Caption
    End Sub

    It works the first time you click the cmd1 button, but after that, it doesnt stop anymore...anyone know what is wrong with it?
    (i have 8 labels positioned with numbers 1 to 8 on them and wherever img1 lands on, that is the number that appears on another label)

  2. #2
    Frenzied Member TomGibbons's Avatar
    Join Date
    Feb 2002
    Location
    San Diego, CA Previous Location: UK
    Posts
    1,345
    try putting your code in [ vbcode ]...[ /vbcode ] tags, it makes it easier to read. Also give more information, what is it supposed to do??

  3. #3
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    in endgame you have to reset jump to 0 or else it will keep counting 20, 21,22....
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2002
    Posts
    4
    how do i reset the timer to 0?

    isnt that what "timer1.interval = 0" command does?

    there are an array of 8 labels in a row and each label has a number from 1 to 8 on them. the arrow moves left to right above these labels...
    this program makes an image(of an arrow) randomly jump from left to right 20 times and stops on the 20th jump. wherever that image stops determines the number that will be printed on another label on the form.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width