ParamArray




Public Sub FillList(ListControl As ListBox, ParamArray Items())
Dim i As Variant
With ListControl
.Clear
For Each i In Items
.AddItem i
Next
End With
End Sub

Private Sub Command1_Click()
FillList List1, "TiffanyT", "MikeS", "RochesterNY"
End Sub

You can use the ParamArray keyword in the declaration line
of a method to create a subroutine or function that accepts
an arbitrary number of parameters at runtime.
For example, you can create a method that will fill a list box
with some number of items even if you do not know the number
of items you will be sent. Add the method below to a form:










( paramarray.html )- by Paolo Puglisi - Modifica del 17/12/2023