1 Replies - 2617 Views - Last Post: 19 February 2010 - 11:30 PM

#1 Nikhil_07n   User is offline

  • The cheese stands alone..
  • member icon

Reputation: 54
  • View blog
  • Posts: 2,490
  • Joined: 09-January 09

Distance between two points.

Posted 03 May 2009 - 06:36 AM

Description: Takes X,Y,Z coordinates of both points as Input and calculates the distace between them.
'====Paste the following code in a form Module=====
'===================================================

Private Sub cmd1_Click()

Dim ptFirst(1 to 3) as Integer
Dim ptSecond(1 to 3) as Integer
Dim tmpVar(1 to 3) as Integer
Dim Dist

Msgbox("Enter the X,Y,Z coordinates of the point 1")
For i = 1 to 3
ptFirst(i)=Inputbox("Enter")
Next i

Msgbox("Enter the X,Y,Z coordinates of the point 2")
For i= 1 to 3
ptSecond(i)=Inputbox("Enter")
Next i

For i = 1 to 3
tmpVar(i)= (ptFirst(i)-ptSecond(i))^2
Next i

Dist = 0
For i= 1 to 3
Dist = Dist + tmpVar(i)
Next i

Dist = Dist ^ (1/2)

Print "The Distance between the two given points is=> " & Dist

End Sub

'=================END===============================
'===================================================


Is This A Good Question/Topic? 0
  • +

Replies To: Distance between two points.

#2 Eliminator2009   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 20-February 10

Re: Distance between two points.

Posted 19 February 2010 - 11:30 PM

The code is good but kindly declare i as integer.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1