Use ParamArray to Accept an Arbitrary Number of Parameters
Submitted by Michael C. Amundsen, mike_tips@amundsen.com, http://www.amundsen.com
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:
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
Note that the ParamArray keyword comes BEFORE the parameter in the declaration line. Now add a list box to your form and a command button. Add the code below in the "Click" event of the command button.
Private Sub Command1_Click()
注释:
FillList List1, "TiffanyT", "MikeS", "RochesterNY"
注释:
End Sub
文章来源于领测软件测试网 https://www.ltesting.net/
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073










