B4X:

```
Sub Globals
'Declare the global variables here.
Dim NR(500) As STRING ' Point name
Dim X(500),Y(500) As DOUBLE ' Coordinates
Dim POINT1,POINT2
Dim NAME1,NAME2
End Sub
' ** CALCULATES DISTANCE FROM COORDINATES
Sub App_Start
Form1.Show
POINT1=-1
POINT2=-1
' testing data
NR(0)=100
X(0)=52000.0
Y(0)=35000.0
For I=1 To 99
NR(I)=NR(I-1)+ 1
X(I)=X(I-1)+ 50.
Y(I)=Y(I-1)+ 60.
Next I
' show points for selecting
For I=0 To 99
ListBox1.Add(NR(I))
ListBox2.Add(NR(I))
Next I
End Sub
Sub ListBox1_SelectionChanged (Index, Value) 'select first point
POINT1=Index
NAME1=Value
Label6.Text=NAME1
DIST
End Sub
Sub ListBox2_SelectionChanged (Index, Value) 'select second point
POINT2=Index
NAME2=Value
Label8.Text=NAME2
DIST
End Sub
Sub Button1_Click
AppClose
End Sub
Sub DIST
Dim DX,DY,S
If POINT1>-1 AND POINT2>-1 Then
DX=X(POINT1)-X(POINT2)
DY=Y(POINT1)-Y(POINT2)
S=DX*DX+DY*DY ' computed distance
Label2.Text=Format(Sqrt(S),"F2")
End If
End Sub
```

numerus