EXCEL VBA 使用 msgbox 在组合框中显示项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17388492/
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-11 21:58:15 来源:igfitidea点击:
EXCEL VBA Use msgbox to show items in combobox
提问by 4 Leave Cover
First: When initialize the userform
第一:初始化用户表单时
I initialize my page by using code below so that it will populate my combobox.
我使用下面的代码初始化我的页面,以便它填充我的组合框。
For Each cell In rangeA
If cell.Value <> "" Then
ComboBox1.AddItem cell.Value
Else
End If
Next
Next
下一个
I have a button to prompt a msgbox that will call all the items inside my combobox. How do I do this? Thanks in advance.
我有一个按钮来提示一个 msgbox,它将调用我的组合框中的所有项目。我该怎么做呢?提前致谢。
回答by Axel Kemper
This can be done as follows:
这可以按如下方式完成:
Private Sub ShowComboBoxAsMsgBox()
Dim s As String
Dim sep As String
Dim i As Integer
For i = 0 To Me.ComboBox1.ListCount - 1
s = s & sep & Me.ComboBox1.List(i)
sep = vbCrLf
Next i
MsgBox s, vbInformation, "my ComboBox"
End Sub