bonjour,
j'ai un petit problème, quand je veux que ma fonction retourne un array, j'ai le message d'erreur suivant :
Erreur de compilation
un appel de fonction dans la partie gauche de l'affectation doit renvoyer Variant ou Objet
et voici le code
Function stock() As Integer()
ReDim stock(19)
For i = 0 To 19
stock(i) = Cells(i + 1, 1).Value
Next i
End Function
Sub affich(ByRef stock() As Integer)
For i = 0 To 19
MsgBox (stock()(i))
Next i
End Sub
Sub launcher()
Call affich(stock)
End Sub
quelqu'un peut-il m'aider?
merci d'avance
EDIT : c'est bon, j'ai trouver tout seul, il suffit de passer par une variable temporaire... :/
Function stock() As Integer()
Dim result(19) As Integer
For i = 0 To 19
result(i) = Cells(i + 1, 1).Value
Next i
stock = result
End Function
Sub affich(ByRef stock() As Integer)
For i = 0 To 19
MsgBox (stock()(i))
Next i
End Sub
Sub launcher()
Call affich(stock)
End Sub