listcount -1的含义是什么?

我一直在寻找互联网试图find什么意思listcount -1是,但我似乎无法find确切的答案。

为什么在listcount旁边有-1 ? 或.list(.listcount -1,1)是什么意思?

编辑

listcount的例子

.additem a.value

.list(.listcount -1, 1) = ws.cells(A,B).value

这将ws.cells(A,B)的值添加到listbox1,但我不明白为什么/如何?

或者我在互联网上find一个code http://www.ozgrid.com/VBA/multi-select-listbox.htm

我明白代码的目的是“如果其中一个列表被选中,然后将列表框的值传递到单元格”,但为什么有.Listbox1.Listcount -1

为了使事情更清楚,正如我所说的,当计数ListBox项目或List时, ListCount1开始。
但是这些项目或List ListBox Indexing0开始。 在你的例子中,你正试图在一个Multi-Column ListBox添加一个项目或List
看看下面的例子:

 With me.ListBox1 .Add "Item1" .List(.ListCount - 1, 1) = "Item2" .List(.ListCount - 1, 2) = "Item3" End With 

上面的代码填充了一个最初由3列设置的ListBox
这行.Add "Item"ListBox添加第一个List
但是你需要填充其余的列。
要访问这些列,可以使用以下语法的.List属性:

 expression.List(pvargIndex, pvargColumn) 

pvargIndexListBox ListIndexpvargColumns是列号。
请记住,您已经使用.Add属性添加了1个item ,并且该项目的ListIndex是?

 .ListCount - 1 'which is current item count in the ListBox less one equal to 0 

要了解更多关于使用ListBox ,请检查一下。
另见这里 。
希望以上帮助你莫名其妙。