|
|
 |
|
|
|
|
|
|
|
|
Visual Basic 2008 9.0 .NET Examples and Ebook
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|