Gruppe
Matrix
Problem
Wie kann ich Matrizen in benutzerdefiniereten Funktionen handhaben? Wie kann ich einzelne Werte zurückgeben lassen?
StandardModule: basMain
Sub Probieren()
Dim arrBasis As Variant
Dim arrErgebnis As Variant
arrBasis = Array(1, 2, 3, 4, 5, 6)
arrErgebnis = Berechnen(arrBasis)
MsgBox arrErgebnis(2)
End Sub
Private Function Berechnen(Basis As Variant) As Variant
Dim iCounter As Integer, iValue As Integer
Dim Ergebnis()
For iCounter = 0 To UBound(Basis) - 1
If Basis(iCounter) Mod 2 = 0 Then
iValue = iValue + 1
ReDim Preserve Ergebnis(iValue)
Ergebnis(iValue) = Basis(iCounter)
End If
Next iCounter
Berechnen = Ergebnis
End Function