我在VBA中的userform中有一个组合框,并希望将用户选择为变量。 IE,我有一个值为1-50的组合框,想要取他们选择的数字并将其用作变量。感谢。
答案 0 :(得分:1)
你可以;
Dim str as String
''always available, what was selected or typed into the box:
str = TheComboBox.Text
msgbox "drop down text: " & str
''for drop-downs, always returns the text of an item:
if (TheComboBox.ListIndex > -1) then
''something is selected;
str = TheComboBox.List(ComboBox1.ListIndex)
msgbox "drop down value: " & str
end if