# Distance between two points.

Page 1 of 1

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

### #1 Nikhil_07n

• The cheese stands alone..

Reputation: 54
• 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

Reputation: 0
• 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.