15,794,850 members
2.00/5 (1 vote)
See more:
Hello
I have a question that i wish to answer it.
I'm vb.net programmer
Let's say that we have two objects (A,B)
how can I move object "A" from its location toward object "B" location straightly with vb.net.

And Thank You.
Posted
Updated 16-Dec-10 2:30am
v2
Toniyo Jackson 16-Dec-10 7:30am
Spell check
#realJSOP 16-Dec-10 7:33am
What do you mean by "move A toward B"?
Is these two objects in a collection?

## Solution 1

Take the coordinates for both objects AX,AY and BX,BY.
Now you have to points and you linearily interpolate all
the points on the line between AX,AY and BX,BY.
Use AX,AY as start point and BX,BY as the endpoint.
Use the interpolated points to move object A towards object B.

Cheers,

Manfred

## Solution 2

I assume you would like to move an object towards another on screen.

Lets say object a is 100 units below object b and also 200 units right of object b. This means that for every unit a moves up it has to move `1 * (200 / 100) = 2` units to the left. This also means that for every single unit it moves to the left it has to move `1 * (100 / 200) = 0.5` units up.

Good luck!

Top Experts
Last 24hrsThis month
 Richard Deeming 90 Maciej Los 10 Rick York 10 Richard MacCutchan 10 KarstenK 10
 Andre Oosthuizen 240 Rick York 170 Maxim Kartavenkov 90 Richard Deeming 90 Maciej Los 75

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900