1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
Sub principale()
Dim table1 As Variant 'le type est Variant, i&
'---
'divers traitement... et ensuite
table1 = maFonction("toto", "kiki", "zaza")
'et ensuite utiliser valeurs contenue dans la table
For i& = LBound(table1) To UBound(table1)
MsgBox table1(i&)
Next i&
table1 = maFonction("Moi")
For i& = LBound(table1) To UBound(table1)
MsgBox table1(i&)
Next i&
table1 = maFonction("Moi", "Toi")
For i& = LBound(table1) To UBound(table1)
MsgBox table1(i&)
Next i&
table1 = maFonction("Moi", "Toi", "lui", "nous", "eux", "autre", "Bof", "Truc", "Machin")
For i& = LBound(table1) To UBound(table1)
MsgBox table1(i&)
Next i&
End Sub
Function maFonction(ParamArray Plage()) As Variant 'le type du retour est Variant
Dim argTableA() As String, i As Long
'---
'divers traitement... et ensuite
For i = 0 To UBound(Plage)
ReDim Preserve argTableA(i)
argTableA(i) = Plage(i)
Next
maFonction = argTableA
End Function |
Partager