listcount -1的含义是什么? [英] what's the meaning of listcount -1

查看:864
本文介绍了listcount -1的含义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在互联网上搜索,试图找出 listcount -1 的含义,但我似乎找不到确切的答案。

I've been searching on the internet trying to find what the meaning of listcount -1 is, but i can't seem to find the exact answer.

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

why is there -1 beside the listcount? or .list(.listcount -1,1) what is that mean?

编辑

edit

listcount的示例

example of the listcount

.additem a.value

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

将$ code> ws.cells(A,B)的值添加到listbox1,但我不明白为什么/怎么样?

this adds the value of ws.cells(A,B) to the listbox1 but i don't understand why/how?

或者我在互联网上找到一个代码 http://www.ozgrid.com/VBA/multi-select-listbox.htm

or i found a code on the internet http://www.ozgrid.com/VBA/multi-select-listbox.htm

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

i understand that the purpose of the code is "if one of the list is selected, then transfer the value of listbox into cells" but why is there .Listbox1.Listcount -1?

推荐答案

为了使事情更清晰,正如我所说, ListCount 1 开始时,计数 ListBox 项目或列表。 br>
但是列表框索引这些项目或列表开始于 0
在您的示例中,您尝试在多列列表框中添加项目或列表

看下面的例子:

To make things clearer, as I've said, ListCount starts at 1 when counting ListBox items or List.
But ListBox Indexing of those items or List starts at 0. In your example, you are trying to add an item or List in a Multi-Column ListBox.
Take a look at below example:

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

以上代码填充了最初设置为3列的 ListBox

这行 .AddItem ListBox中添加了第一个列表 / code>。

但您需要填充其余的列。

要访问这些列,请使用 .List property with this syntax:

Above code populates a ListBox initially set with 3 columns.
This line .Add "Item" adds the first List in the ListBox.
But you need to populate the rest of the columns.
To access those columns, you use .List property with this syntax:

expression.List(pvargIndex, pvargColumn)

pvargIndex ListBox ListIndex pvargColumns 是列号。

请记住,您已经添加了1个项目 。添加属性和t他的 ListIndex

pvargIndex is the ListBox ListIndex and pvargColumns is the column number.
Remember that you already added 1 item using the .Add property and the ListIndex of that item is?

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

要了解更多关于pupulating ListBox ,检查这个

另请参阅 HERE

以上希望可以帮助您。

To learn more about pupulating ListBox, check THIS out.
Also see HERE.
Hope above helps you somehow.

这篇关于listcount -1的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆