Function returns empty?!?

Function returns empty?!?

Anonymous
Not applicable
356 Views
2 Replies
Message 1 of 3

Function returns empty?!?

Anonymous
Not applicable
This call
leaddist = UsePoint(leadhead, vertices)

Comes up empty from this function:

Public Function UsePoint(A As Variant, B As Variant) As Variant
Dim MinDist As Double
Dim DistTest As Double
Dim TestPt(2) As Variant
Dim MinPt As Variant
Dim i As Integer

MinDist = 1E+100 'Unusually large value to rig test case below
For i = 0 To 6 Step 2
TestPt(0) = B(i): TestPt(1) = B(i + 1): TestPt(2) = 0# 'Sets TestPt
array values
DistTest = Sqr(((A(0) - TestPt(0)) ^ 2 + (A(1) - TestPt(1)) ^ 2))
If DistTest < MinDist Then
MinDist = DistTest
MinPt = TestPt()
End If
Next i
Set UsePoint = MinPt()
End Function

I'm trying to find the nearest point on a rectangle (vertices) to the point
picked (leadhead) so that I can add a leader. Watching the function,
everything looks OK, but as soon as it returns to the main call, the
leaddist variant is empty. What am I missing.

Thanks as always for any help!
--
James Wedding, EIT
Jones & Boyd, Inc.
Dallas, Texas
[email protected]
REMOVE NOSPAM FOR REPLY
0 Likes
357 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Try UsePoint = MinPoint.

--
DSX Professional
The power of AutoCAD and Windows united
http://www.acadx.com
0 Likes
Message 3 of 3

Anonymous
Not applicable
D'oh. I thought I had tried that. Thanks as always, Frank.


--
James Wedding, EIT
Jones & Boyd, Inc.
Dallas, Texas
[email protected]
REMOVE NOSPAM FOR REPLY
0 Likes