D.2. Functions Can Return Arrays

Functions and property procedures can now return arrays of any type. Previous versions of VB allowed you to return a variant data type containing an array, but now you can return a strongly typed array. For example:

Dim sArray() As String
Dim oCustomers As New Customers
sArray() = oCustomers.Names

Public Property Get Names() As String()
    Dim TempArray() As String
    '...code to get all the names of the customers
         Names = TempArray()
End Function

For information, see the entry for the Function statement in Chapter 7.

Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.