Function declaration syntax

Function declaration syntax

Anonymous
Not applicable
426 Views
3 Replies
Message 1 of 4

Function declaration syntax

Anonymous
Not applicable
Is there a syntactically correct way to do something like this?:

Dim Pnt(0 To 2) As Double
Dim myEntity As AcadEntity

Public Function FindPt(ent As AcadEntity)(0 To 1) As Double
.
.
.
End Function

Pnt = FindPt(myEntity)


or do I have to have the funtion return a Variant? If I do then it seems I get a type mismatch.
0 Likes
427 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Public Function FindPointOnEntity() As Double()
Dim tempPoint(0 To 2) As Double

'Calculate the point values

FindPointOnEntity = tempPoint()
End Function


Public Sub TestFindPointOnEntity()
Dim startPoint() As Double

startPoint() = FindPointOnEntity()
End Sub

But I think you'll find that using a class is much more convenient and
flexible than passing around an array.
--
Bobby C. Jones

wrote in message news:[email protected]...
> Is there a syntactically correct way to do something like this?:
>
> Dim Pnt(0 To 2) As Double
> Dim myEntity As AcadEntity
>
> Public Function FindPt(ent As AcadEntity)(0 To 1) As Double
> .
> .
> .
> End Function
>
> Pnt = FindPt(myEntity)
>
>
> or do I have to have the funtion return a Variant? If I do then it seems
I get a type mismatch.
0 Likes
Message 3 of 4

Anonymous
Not applicable
You declare Pnt as array (its elements are double), while the function
returns a double, not an array, hence the type mismatch.

If the function returns an array of double values, it should be:

Public Function FindPoint(ent As AcadEntity) As Double()
'Do something
FindPoint=pt 'pt is an array of double values
End Finction

Or

Public Function FindPoint(ent As AcadEntity) As Variant
'Do something
FindPoint=pt 'pt is an array of double values
End Finction

wrote in message news:[email protected]...
> Is there a syntactically correct way to do something like this?:
>
> Dim Pnt(0 To 2) As Double
> Dim myEntity As AcadEntity
>
> Public Function FindPt(ent As AcadEntity)(0 To 1) As Double
> .
> .
> .
> End Function
>
> Pnt = FindPt(myEntity)
>
>
> or do I have to have the funtion return a Variant? If I do then it seems
I get a type mismatch.
0 Likes
Message 4 of 4

Anonymous
Not applicable
Thank you
0 Likes