Some code help needed!

CaptainCool
09-07-2003, 11:03 AM
I have a picture of a car that I want to move back and forth on the screen constantly. here is the code I have so far.

Private Sub tmrTimer1_Timer()
If imgCar.Left > 5000 And blnLeft Then
imgCar.Left = imgCar.Left - 75
ElseIf imgCar.Left < 75 Then
blnLeft = False
blnRight = True
ElseIf imgCar.Left < 8000 And blnRight Then
imgCar.Left = imgCar.Left + 75
ElseIf imgCar.Left > 8000 Then
blnRight = False
blnLeft = True
imgCar.Left = imgCar.Left - 75
End If
End Sub

This makes the car go left but then it stops and doesn't go back to the right.
Any one know how I could fix this?

thanks and advanced!

zak2zak
09-07-2003, 11:32 AM
May be this helps...
Just use the following code
Please Declare at to Declaration

'Declaration
bMove As Boolean
------------------------------
Private Sub tmrTimer1_Timer()
If Not bMove Then
imgCar.Move imgCar.Left + 50 '50 can be change to any as u want
Else
imgCar.Move imgCar.Left - 50
End If

If imgCar.Left >= 5000 Then
bMove = True
ElseIf imgCar.Left <= 75 Then
bMove = False
End If
End Sub

CaptainCool
09-07-2003, 11:49 AM
It worked! Thanks dude. :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum