vba 如何在组合框中找到所选选项的索引?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1593627/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 10:04:34  来源:igfitidea点击:

How can I find the index of the selected choice in a combobox?

excelvbacombobox

提问by emre

How do I access the SelectedIndex of an ActiveX combobox object in Excel? I need an integer.

如何在 Excel 中访问 ActiveX 组合框对象的 SelectedIndex?我需要一个整数。

回答by Ant

I think combo.ListIndexis the property you're looking for...

我认为combo.ListIndex是您正在寻找的财产...

回答by RBarryYoung

The .ListIndex property works if only one item is selected, however, you need to browse the .Selected collection if you allow multiple selections.

如果仅选择一项,则 .ListIndex 属性有效,但是,如果允许多项选择,则需要浏览 .Selected 集合。