Results 1 to 2 of 2

Thread: Return array from a Function

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2010
    Posts
    87

    Return array from a Function

    How do you send back an array from a function?

    In VBA you just assign an array:

    Code:
    Function arr...
        a=1
        b=2
        c=3
        arr=Array(a,b,c)
    End Function
    Sub retarr()
        x=1
        arrret=arr(x)
        aret=arret(0)
        bret==arret(1)
        cret==arret(2)
    ...
    End Sub
    How do you do it in vb.net and asp.net?
    Last edited by Philosophaie; Dec 4th, 2013 at 08:31 PM.

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: Return array from a Function

    you return it the same as you would any other function
    Code:
    Private Function foo() as integer()
        dim retArr as Integer(5)
        retArr(0) = 1
        retArr(1) = 2
        retArr(2) = 3
        retArr(3) = 4
        retArr(4) = 5
        return retArr
    End function
    
    private sub bar()
        dim myArray as Integer()
        myArray = foo
    End Sub
    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width