Message 1 of 3
Function returns empty?!?
Not applicable
07-13-2001
06:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
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