我一直在互联网上搜索,试图找到的含义listcount -1
是什么,但我似乎找不到确切的答案。
为什么-1
在listcount旁边?或.list(.listcount -1,1)
那是什么意思?
编辑
listcount的示例
.additem a.value
.list(.listcount -1, 1) = ws.cells(A,B).value
这增加了ws.cells(A,B)
到listbox1的价值,但我不明白为什么/如何做?
或者我code
在互联网上找到了http://www.ozgrid.com/VBA/multi-select-listbox.htm
我知道该代码的目的是“如果选择了列表之一,则将列表框的值转移到单元格中”,但是为什么会出现.Listbox1.Listcount -1
呢?
正如我已经说过的,为了使事情更清楚,ListCount
从1
计算ListBox
项目或时开始List
。
但是ListBox Indexing
这些项目还是List
从开始0
。在你的榜样,您要添加一个项目或List
一个Multi-Column ListBox
。
看下面的例子:
With me.ListBox1
.Add "Item1"
.List(.ListCount - 1, 1) = "Item2"
.List(.ListCount - 1, 2) = "Item3"
End With
上面的代码ListBox
用3列填充了一个初始集合。
这条线路.Add "Item"
将第一List
的ListBox
。
但是您需要填充其余的列。
要访问这些列,请使用.List
具有以下语法的属性:
expression.List(pvargIndex, pvargColumn)
pvargIndex
是ListBox ListIndex
和pvargColumns
是列号。
还记得您已经item
使用.Add
属性添加了1 ,ListIndex
而该项目的是?
.ListCount - 1 'which is current item count in the ListBox less one equal to 0
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句