Tutorial by Examples

You can copy a VBA array into an array of the same type using the = operator. The arrays must be of the same type otherwise the code will throw a "Can't assign to array" compilation error. Dim source(0 to 2) As Long Dim destinationLong() As Long Dim destinationDouble() As Double dest...
A function in a normal module (but not a Class module) can return an array by putting () after the data type. Function arrayOfPiDigits() As Long() Dim outputArray(0 To 2) As Long outputArray(0) = 3 outputArray(1) = 1 outputArray(2) = 4 arrayOfPiDigits = outputArray ...
Arrays can be passed to proceedures by putting () after the name of the array variable. Function countElements(ByRef arr() As Double) As Long countElements = UBound(arr) - LBound(arr) + 1 End Function Arrays must be passed by reference. If no passing mechanism is specified, e.g. myFunction...

Page 1 of 1