Problem moving image around screen

I have wrote a program in VB to move a image of a car around the screen. The image should start at the bottom left hand side of the screen, move to the top and then down to where it began.
I can get the image to move to the right and top but I am unable to move it to the left and down to the starting position.  Option Explicit

Private Sub cmdExit_Click()
End
End Sub

Private Sub cmdGo_Click()
Do
imgCar.Left = imgCar.Left + txtSpeed.Text
Loop Until imgCar.Left > 10000
Do
imgCar.Top = imgCar.Top - txtSpeed.Text
Loop Until imgCar.Top > 2000

Do
imgCar.Left = imgCar.Left - txtSpeed.Text
Loop Until imgCar.Left < 1000

Do
imgCar.Top = imgCar.Top - txtSpeed.Text
Loop Until imgCar.Top > 1680


End Sub

Private Sub cmdStart_Click()


lblPrompt.Caption = "Enter Speed then press Go"
'here the speed box appears for the first time
'and the above text appears after the next statement
txtSpeed.Visible = True
txtSpeed.Text = "0"
cmdGo.Enabled = False
'move the pointer into the speed setting box
txtSpeed.SetFocus

End Sub

Private Sub txtSpeed_Change()
cmdGo.Enabled = True
End Sub

GsmithAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

smeggheadCommented:
What's the engine size of the car ??
0
GsmithAuthor Commented:
Edited text of question.
0
GsmithAuthor Commented:
oops !Is that better smeghead?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

GsmithAuthor Commented:
Edited text of question.
0
caraf_gCommented:
Try changing
Do
imgCar.Top = imgCar.Top - txtSpeed.Text
Loop Until imgCar.Top > 1680


to
Do
imgCar.Top = imgCar.Top - txtSpeed.Text
Loop Until imgCar.Top < 1680


0
smeggheadCommented:
And probably...

imgCar.Top = imgCar.Top - txtSpeed.Text
Loop Until imgCar.Top > 2000

to

imgCar.Top = imgCar.Top - txtSpeed.Text
Loop Until imgCar.Top < 2000
0
smeggheadCommented:
Just a thought, you might find it easier to use a for...next loop for this purpose, it's a bit easier to maintain..

For CurX=1 to 2000 step val(txtspeed.text)
imgcar.Left=CurX
Next CurX
0
caraf_gCommented:
Ah. oops! I forgot, you want to move from bottom left to top right and back...

Do
imgCar.Left = imgCar.Left + txtSpeed.Text
Loop Until imgCar.Left > 10000
Do
imgCar.Top = imgCar.Top - txtSpeed.Text
Loop Until imgCar.Top < 2000

Do
imgCar.Left = imgCar.Left - txtSpeed.Text
Loop Until imgCar.Left < 1000

Do
imgCar.Top = imgCar.Top + txtSpeed.Text
Loop Until imgCar.Top > a bigger number, e.g. 10000?




0
Erick37Commented:
And also...

Private Sub cmdExit_Click()
End
End Sub

to

Private Sub cmdExit_Click()
    Unload Me
End Sub

Using End statement will terminate the program without unloading from memory.

And maybe use Val(txtSpeed.Text) to convert the string to a number.
0
GsmithAuthor Commented:
I have altered the program, I find that I can move the image from the bottom left corner to the bottom right corner, the image also moves to the top right hand corner and then to the top left hand corner. The problem I have now with the loop is that I cannot move it from the top left hand corner back to the bottom left hand corner



Option Explicit

Private Sub cmdExit_Click()
End
End Sub

Private Sub cmdGo_Click()
Do
imgCar.Left = imgCar.Left + txtSpeed.Text
Loop Until imgCar.Left >= 10000
Do
imgCar.Top = imgCar.Top - txtSpeed.Text
Loop Until imgCar.Top <= 2000

Do
imgCar.Left = imgCar.Left - txtSpeed.Text
Loop Until imgCar.Left <= 1000

Do
imgCar.Top = imgCar.Top - txtSpeed.Text
Loop Until imgCar.Top <= 2000

End Sub

Private Sub cmdStart_Click()


lblPrompt.Caption = "Enter Speed then press Go"
'here the speed box appears for the first time
'and the above text appears after the next statement
txtSpeed.Visible = True
txtSpeed.Text = "0"
cmdGo.Enabled = False
'move the pointer into the speed setting box
txtSpeed.SetFocus

End Sub

Private Sub txtSpeed_Change()
cmdGo.Enabled = True
End Sub
0
caraf_gCommented:
Option Explicit

Private Sub cmdExit_Click()
End
End Sub

Private Sub cmdGo_Click()
Do
imgCar.Left = imgCar.Left + txtSpeed.Text
Loop Until imgCar.Left >= 10000
Do
imgCar.Top = imgCar.Top - txtSpeed.Text
Loop Until imgCar.Top <= 2000

Do
imgCar.Left = imgCar.Left - txtSpeed.Text
Loop Until imgCar.Left <= 1000

Do
imgCar.Top = imgCar.Top + txtSpeed.Text
Loop Until imgCar.Top >= 8000 'or some other large number.

End Sub

Private Sub cmdStart_Click()


lblPrompt.Caption = "Enter Speed then press Go"
'here the speed box appears for the first time
'and the above text appears after the next statement
txtSpeed.Visible = True
txtSpeed.Text = "0"
cmdGo.Enabled = False
'move the pointer into the speed setting box
txtSpeed.SetFocus

End Sub

Private Sub txtSpeed_Change()
cmdGo.Enabled = True
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GsmithAuthor Commented:
Thanks, program is now working

 
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.