im doin my final year project nw..its abt map...how i want to calculate distence between 2 points by clicking on that point1 and drag until another point2.
i realy dun hv idea to do..realy need help from your guyz..thank you

Recommended Answers

All 7 Replies

You'll need to track mouse down and mouse up events, then use the Pythagorean theorem.

Hope this helps.

ya..but i dont know to make it in vb..
can give example code ..?

im doin my final year project nw..its abt map...how i want to calculate distence between 2 points by clicking on that point1 and drag until another point2.
i realy dun hv idea to do..realy need help from your guyz..thank you

can help me in the coding by giving example coding.

No, shinchan, we won't do your homework for you. If your professor has asked you to do something with tools he has not taught you, go see the department chair or the ombudsman. Otherwise, if you haven't paid enough attention in class to pass the assignment then you are going to fail it. Sorry.

If you try to do it, and post here with what you have got, and where it goes wrong, etc. we will help you.

Count me in Duoas, yeah he didn't even give a try...

Count me in Duoas, yeah he didn't even give a try...

try to use this sample code

Public Function DistanceBetween(ByVal X1 As Single, ByVal Y1 As Single, ByVal X2 As Single, ByVal Y2 As Single) As Single
  ' Calculate the distance between two points, given their X/Y coordinates.

  ' The short version...
  DistanceBetween = Sqr((Abs(X2 - X1) ^ 2) + (Abs(Y2 - Y1) ^ 2))

  ' The longer version, to illustrate how it works...
  Dim Horizontal As Single, Vertical As Single
  Horizontal = Abs(X2 - X1)
  Vertical = Abs(Y2 - Y1)
  DistanceBetween = Sqr((Horizontal * Horizontal) + (Vertical * Vertical))
End Function
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.