我有一个列表框。如何从多个项目中选择列表框中的第三个项目?
答
您可以将10个列表框转换为控件数组。如果我没有记错,您可以通过为表单中的每个ListBox
实例指定相同的Name
属性和唯一的非负Index
属性。
假设你命名你所有的列表框为ListBoxArr
,并成立了Index
属性,以便第一列表框是0,第二个是1,等等,那么你可以写这样的事情
' Access the 6th list box and select the third item
' Remember, Index values are zero-based, so 0 is first item...
ListBoxArr(5).ListIndex = 2