• 0

Making an object move in visual basics


Question

I need some help on a code you can't use steps also known as twilps i think to move the object. Is a way to make it move foward, slow foward, and to go back. I mean thats all i need basically some other way instead of using the step known as twilps. Here is an image about it i don't know how else to make it move. Any help would be appreciated i also have a picture of what i am working at.

http://img339.imageshack.us/my.php?image=sputnickpicrj1.jpg

8 answers to this question

Recommended Posts

  • 0

image1.left = image1.left + 50 (It'll go right)

image1.left = image1.left - 50 (It'll go left)

image1.top = image1.top - 50 (Up)

image1.top = image1.top + 50 (down)

Add that into a timer, is what I used to do..

Alter the number 50 for speed... the lower the number the slower it goes...

  • 0

Wow that was a fast reply by any chance you don't have another way cuz that seems the only other way i got cuz in the book they have this one. Also how do i make it go slow i don't understand you said with the timer sorry i am not really good in visual basics but you really did help me i just need to make it slow :D i really appreciated.

Dim IntCount As Integer
for intCount = 240 to 6100 Step 10
imgSatellite.Left = intCount 
Next intCount
End sub

Your way was so easy and quick the teacher didn't want us to do it that way because of some bug i just wanted to ask if by any chance you knew another way if not i will keep yours since it doesn't seem like the books way. Thanks for the response i really appreciate your help :D

  • 0

Sorry for the post no it hasn't failed, just wanted to see if there was another way since the teacher i have is really picky at times its different from the book as i see as well and i haven't had a problem right now that i tested it all i would need is the slow to work can you explain it more thank you i really once again appreciate your help on this.

  • 0

Well I imagine you'd set the timer to one millisecond... (timer1.interval = 1)

image1.top = image1.top - 50

What that line does is moves image1 50 pixels up every time it is run...aka every millisecond.

Changing that number to 25

image1.top = image1.top - 25

moves it up 25 pixels/millisecond and so it'll move slower...

dim imgspeed as integer

imgspeed = 50 ' Set this value lower to make it go slower....

image1.top = image1.top - imgspeed

I probably didn't explain that too well...sorry, it's late and I'm tired...

edit: Fixed stupid typing errors.

Edited by simsie
  • 0

I made the one that goes fast work and go back work. I can't seem to make the one to go slowly front to work. Here is what i have in the code so far.

Option Explicit

Private Sub cmdClose_Click()
	' End the application.
	End
End Sub

Private Sub cmdGo_Click()
imgSatellite.Left = imgSatellite.Left + 5900
End Sub

Private Sub cmdGoBack_Click()
imgSatellite.Left = imgSatellite.Left - 5900
End Sub

Private Sub cmdGoSlow_Click()
Dim imgspeed As Integer
imgspeed = 50
imgSatellite.Left = imgSatellite.Left + imgspeed
End Sub

So I just need to somehow make the go slow work which i don't understand what to put inside. When i press it just moves a little i need to make it work so it can make it all the way but going slowly Any help would be appreciated. Also here is an image.

http://img169.imageshack.us/my.php?image=watchrz8.jpg

  • 0

Put lines like:

imgSatellite.Left = imgSatellite.Left + 5900

imgSatellite.Left = imgSatellite.Left - 5900

In their own timers...set them to disabled...

In each of the command buttons put

timer1.enabled = true

Then in the timer you put how long you want it to run for...

If you want I can chuck together a quick example...

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.