andrewo
07-01-2001, 02:45 AM
Hey I want to know if its possible to..
have a line drawn and an object like..command button to move along it?
~
have a line drawn and an object like..command button to move along it?
~
Making a commmand button follow a line..run alongandrewo 07-01-2001, 02:45 AM Hey I want to know if its possible to.. have a line drawn and an object like..command button to move along it? ~ Ad1 07-01-2001, 08:41 AM if you have a line and set X1 and Y1 on the object, then set X2 and Y2 where you want your object to move to then you could put something like <pre>Xmove=(line1.X2 - line1.X1)/100 Ymove=(line1.Y2-line1.Y1)/100 for i=1 to 100 command1.left=command1.left + Xmove command1.top=command1.top + Ymove next i</pre> Defiance 07-01-2001, 01:10 PM Ok, my way is this. First I make a line with the coordinates of X1: 360 X2: 6240 Y1: 3600 Y2: 3600. I then put a command button with a left coordinate of 360. I added a timer control to the form and set its interval property to 15. I then put this code: <pre>Private Declare Sub Sleep Lib "Kernel32" Alias "Sleep" (byVal dwMilliseconds As Long) Private Sub Timer1_Timer() If Command1.Left <= 360 Then Do Until Command1.Left >= 4800 Command1.Left = Command1.Left + 50 Sleep 50 DoEvents Loop ElseIf Command1.Left >= 4800 Then Do Until Command1.Left <= 360 Command1.Left = Command1.Left - 50 Sleep 50 DoEvents Loop End If End Sub</pre> The command button moved swiftly along the line, but I noticed it made a bit of a shadow like thing that stayed for a millisecond or so. You can try it if you want. --Defiance "Soon I will answer your questions, now you will answer mine..." andrewo 07-02-2001, 05:32 AM thanx they both work great and i probably being using a bit of both, one more question, i was wondering if you could move an object around a drawn circle? like draw a circle and then have a command button move around it. ~ Defiance 07-02-2001, 08:31 AM It's possible, but probably quite hard, since you will constantly have to be checking for the next angle/turn of the circle. That's a little out of my league, sorry. --Defiance "Soon I will answer your questions, now you will answer mine..." |
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum