"Cannot assign whole array"
 
 
 
PST User Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



"Cannot assign whole array" Expand / Collapse
Author
Message
Posted 7/13/2007 12:45:34 PM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 7/30/2007 6:06:51 PM
Posts: 25, Visits: 36
Hello,

 When I try to return an array with a function it gives me this error, what did I do wrong ?

Thanks

Post #485
Posted 7/13/2007 5:40:47 PM
Forum MVP

Forum MVPForum MVPForum MVPForum MVPForum MVPForum MVPForum MVPForum MVP

Group: Administrators
Last Login: Today @ 9:26:59 AM
Posts: 576, Visits: 1,254
Arrays are not allowed as a return type on a function.  However, by default all parameters are passed by reference which means you can edit their contents.

Sub IncrementValuesInArray(a() As Integer)

    Dim x As Long

    For x = LBound(a) To UBound(a)

         a(x) = a(x) + 1

    Next

End Sub

Please see the UBound, LBound, ArrayDims, ReDim, and ReDim Preserve areas of E-Basic Help.

-Brandon

Post #486
Posted 7/16/2007 12:19:16 PM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 7/30/2007 6:06:51 PM
Posts: 25, Visits: 36
Brandon.Cernicky (7/13/2007)
Arrays are not allowed as a return type on a function.  However, by default all parameters are passed by reference which means you can edit their contents.

...

-Brandon

So I guess this means I can't return an array with a function, but I can pass an array to a function (and sub) and modify its content there. Is this right ?

Thanks Brandon !

Post #496
« Prev Topic | Next Topic »


Permissions Expand / Collapse

All times are GMT -5:00, Time now is 11:15pm

Powered By InstantForum.NET v4.1.4 © 2009
Execution: 0.062. 12 queries. Compression Disabled.