return function with multiple objects

return function with multiple objects

wbdehaan
Enthusiast Enthusiast
707 Views
2 Replies
Message 1 of 3

return function with multiple objects

wbdehaan
Enthusiast
Enthusiast

Hi, 

 

I would like to return multiple objects from a function. can it be done? and how?

 

function DrawLines()as object

objline1 as new line

objline2 as new line

[..]

 

return 'objects'

end function

 

sub Main

Dim Group1 as new Arraylist

Group1.Add(DrawLines())

end sub

 

 

kind regards Wouter

 

 

 

0 Likes
Accepted solutions (1)
708 Views
2 Replies
Replies (2)
Message 2 of 3

alberto_manero_geograma
Enthusiast
Enthusiast

Hello!

 

I think the simplyest way to do it is to return an array of lines (or entityes) from your function:

 

Function DrawLines()as line()

   Dim ArOut() As line

   [···]

   Rerutn ArOut

End Function

 

But you may also return a "collection", a "list (Of line)" or another thing...

 

Hope this helps!

Luis Alberto Manero, Geograma.com
0 Likes
Message 3 of 3

wbdehaan
Enthusiast
Enthusiast
Accepted solution

Thanx a lot!

it helped, and i created now an arraylist to return the objects:

 

 

 

    Public Function Drawlines() As ArrayList
        Dim ObjLijn1 As New Line
        Dim ObjLijn2 As New Line
        Dim Lijst As New ArrayList
        ObjLijn1.StartPoint = New Point3d(CenterX + F1, CenterY + Grootte / 2, 0)
        ObjLijn1.EndPoint = New Point3d(CenterX - F1, CenterY - Grootte / 2, 0)
        Lijst.Add(ObjLijn1)
        ObjLijn2.StartPoint = New Point3d(CenterX - Grootte / 2, CenterY + F1, 0)
        ObjLijn2.EndPoint = New Point3d(CenterX + Grootte / 2, CenterY - F1, 0)
        Lijst.Add(ObjLijn2)
        '---Return lijst
        Return Lijst
    End Function

 

 

0 Likes