Search notes:

VBA: returning values from functions

Returning an array from a function

This is how I believe how an array should be returned from a function.
One is wondering if this is really the most elegant approach.
option explicit

function getArray() as string()

    dim ret(3) as string

    ret(1) = "one"
    ret(2) = "two"
    ret(3) = "three"
    
    getArray = ret

end function

sub main()

    dim ary() as string
    
    ary = getArray()
    
    for i = 1 to uBound(ary)
        msgBox(ary(i))
    next i

end sub
Github repository about-VBA, path: /language/subs-and-functions/returning-values/array.bas
See also this link.

See also

VBA: User defined subs and functions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759390503, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/VBA/language/subs-and-functions/returning-values/index(74): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78