problems moving a image around the screen

I have wrote a program to move a image from the bottom left hand corner of the screen, right, top, left and back to the starting position. I can get it to go right, but it then goes left again and stops. I know it is something to do with the > and< and speed, but I seem to not be able to get it in the right order.  


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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
LischkeConnect With a Mentor Commented:
The sub routine should look so:

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

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

Do
imgCar.Top = imgCar.Top + txtSpeed.Text
Loop Until imgCar.Top >= 768


End Sub

Note: I have changed the comparation values to a screen resolution of 1024 x 768 and assume the starting point is the lower left corner (x = 0; y = 768)

Ciao, Mike
0
 
kretzschmarCommented:
uuh mike,
du bist ein vb'ler?
0
 
LischkeCommented:
:-) Ne, glaub's bloss nicht. Ich weiss nicht mal wie VB aussieht, aber vor langer Zeit habe ich mal mit Basic angefangen und was ein richtiger Programmierer ist, der wird doch wohl noch so'n Furzprogramm entlausen koennen :-)

Ciao, Mike
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
kretzschmarCommented:
:-)) ha ha,
das hast du ja auch geschafft
0
 
LischkeCommented:
Not sure about this as Gsmith never replied to my suggestion...

Again such a case we talked about lately...?

Ciao, Mike
0
 
GsmithAuthor Commented:
I have already accepted a answer and have completed the program I now understand what has to be changed. I am now trying another program from the book Into visual Basics. Thank anyway
0
 
LischkeCommented:
Aaah, there he is. Gsmith, I'm pleased that you solved the problem, but you should also spend attention to help you get/got for your questions. My proposed answer here dates from 2. November. You could have accepted or rejected it already a while ago. Keep in mind I (and the other experts) doing help for free!

Ciao, Mike
0
 
GsmithAuthor Commented:
Lets start at the beginning ! I am a she not a he. I did accept an answer from another expert on Visual Basics questions. I did delete this question on programming question page.
0
 
LischkeCommented:
Oh, you are the second girl I meet at E-E. Happens not very often... Perhaps you should sign your comments with your first name so one can see what gender you are :-) (although, it doesn't matter very much).

What I wonder about is that you deleted this question and it is still there. Unfortunately, such things happen from time to time here. Please go to the Customer Support Area and ask for deletion of this question, so you'll get back your points and there's no "ghost" flying around...

Ciao, Mike
0
All Courses

From novice to tech pro — start learning today.