5 Replies - 17133 Views - Last Post: 29 April 2008 - 05:15 AM Rate Topic: -----

#1 liko  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 32
  • Joined: 19-April 08

Moving an object in visual basic

Posted 26 April 2008 - 04:41 PM

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.images...tnickpicrj1.jpg

This post has been edited by liko: 26 April 2008 - 04:43 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Moving an object in visual basic

#2 KG87  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 52
  • Joined: 25-September 07

Re: Moving an object in visual basic

Posted 26 April 2008 - 07:21 PM

View Postliko, on 26 Apr, 2008 - 04:41 PM, said:

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.images...tnickpicrj1.jpg


OK, so you've decided on this project, and no disrespect, but it sounds like a homework question.

so instead of a solution I'll give you some advice.

1. Put some effort into the problem before asking for a solution. I don't exactly think "end" is a valid amount of code. :angry:

2. you will be wanting to move the image.. so better be looking at the positioning attributes such as left and top

3. you will need a timer. setting the interval dependant on how fast you want the object to move.

Hope that puts you on your way, If you need more assistance, do some more work on it, then give us an update :D
Was This Post Helpful? 0
  • +
  • -

#3 liko  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 32
  • Joined: 19-April 08

Re: Moving an object in visual basic

Posted 27 April 2008 - 02:43 AM

Ya its actually a homework assignment. What sucks is there is no clue on it since he gives it out of his own work. I made the one that goes fast work and go back work. I can't seem to make the one to go slowly front. 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.images...ge=watchrz8.jpg

This post has been edited by liko: 27 April 2008 - 02:45 AM

Was This Post Helpful? 0
  • +
  • -

#4 KG87  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 52
  • Joined: 25-September 07

Re: Moving an object in visual basic

Posted 27 April 2008 - 04:51 PM

:rolleyes: ahh ok, been there :D

Your lucky,

Ok so on your form you need

1x command button
1x Frame
2x option buttons, (one named optslow and one opt fast), both of these need to be placed within the frame
1x timer

Private Sub Command1_Click()

If optslow.Value = True Then
Timer1.Interval = 100
Else
Timer1.Interval = 5
End If

Timer1.Enabled = True


End Sub


Private Sub Form_Load()

Timer1.Enabled = False

End Sub


Private Sub Timer1_Timer()

Image1.Left = Image1.Left + 10

If Image1.Left = 12360 Then
Timer1.Enabled = False
MsgBox "end!"
End If


End Sub




Basically, The timer is like the seconds hand on a watch, the interval is the length of that second.

in the timer1_timer section, this is where you would put your code to move the object, its after each "second" that the code here is executed

Ok, so I've pretty much done if for you. I've sympathy cause im finishing my course in 3 weeks :crazy:
Was This Post Helpful? 0
  • +
  • -

#5 liko  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 32
  • Joined: 19-April 08

Re: Moving an object in visual basic

Posted 27 April 2008 - 08:11 PM

View PostKG87, on 27 Apr, 2008 - 04:51 PM, said:

:rolleyes: ahh ok, been there :D

Your lucky,

Ok so on your form you need

1x command button
1x Frame
2x option buttons, (one named optslow and one opt fast), both of these need to be placed within the frame
1x timer

Private Sub Command1_Click()

If optslow.Value = True Then
Timer1.Interval = 100
Else
Timer1.Interval = 5
End If

Timer1.Enabled = True


End Sub


Private Sub Form_Load()

Timer1.Enabled = False

End Sub


Private Sub Timer1_Timer()

Image1.Left = Image1.Left + 10

If Image1.Left = 12360 Then
Timer1.Enabled = False
MsgBox "end!"
End If


End Sub




Basically, The timer is like the seconds hand on a watch, the interval is the length of that second.

in the timer1_timer section, this is where you would put your code to move the object, its after each "second" that the code here is executed

Ok, so I've pretty much done if for you. I've sympathy cause im finishing my course in 3 weeks :crazy:


Yes! Thank you so much i appreciate the help. I suck at visual basics i am finishing visual basic in 5 more weeks as well. You are really good that helped me a lot i appreciate you helping me on the rest thank you so much.
Was This Post Helpful? 0
  • +
  • -

#6 sam_benne  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 16
  • View blog
  • Posts: 732
  • Joined: 16-January 08

Re: Moving an object in visual basic

Posted 29 April 2008 - 05:15 AM

there is another way without using command buttons and that is to use the arrow keys. so something like:
Private Sub Pic1_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyright
		pic1.Left = pic1.left + 5900
End Select
End Sub


and all you would have to do is change the vbkeycode to left or up and add more cases.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1