Visual Basic 2008 9.0 .NET Examples and Ebook
  Home

Procedures and Functions

Vorig Onderwerp

Arrays

|

Object Oriented Programming

Volgend Onderwerp

Returning Arrays

Vorig Onderwerp

Arrays as Arguments

|

Parameter Arrays - ParamArray

Volgend Onderwerp
-


A function can return an array. The type specifier ( As clause ) of that function defines what arraytype is being returned.

Function GetIntegerArray of Example will return an Integer array.


Module Example
    Sub Main()
        Dim values As Integer()
        PrintArray(values)
        '
        values = GetIntegerArray(10)
        PrintArray(values)
        '
        Console.ReadLine()
    End Sub
    Sub PrintArray(ByVal values As Array)
        If values IsNot Nothing Then
            For Each element As Object In values
                Console.Write(element & " ")
            Next
            Console.WriteLine()
        Else
            Console.WriteLine("No array.")
        End If
    End Sub
    Function GetIntegerArray(ByVal capacity As Integer) As Integer()
        Dim integerArray(capacity - 1) As Integer
        GetIntegerArray = integerArray
    End Function
End Module
Download Broncode

Output :

 No array.
 0 0 0 0 0 0 0 0 0 0

A call to the GetIntegerArray function is an expression of type Integer().


Updated On : 2008-11-06

Download Broncode

Published On : 2008-11-06

Returning Arrays

Vorig Onderwerp

Arrays as Arguments

|

Parameter Arrays - ParamArray

Volgend Onderwerp

Procedures and Functions

Vorig Onderwerp

Arrays

|

Object Oriented Programming

Volgend Onderwerp
  Home  
Nederlands
Nederlands

Add to favorites (IE).


No printable version available.