Excel VBA 用户窗体组合框问题
我在 Excel 文档的用户窗体中使用组合框时遇到困难。 组合框要么不出现在用户窗体中,要么组合框保持空白,当我在其中输入任何字符时,项目列表会出现 2 或 3 次,而不是一次。 当我选择一个项目时,所选项目不会出现在框中。看起来好像 Excel^ 随机选择一项,无论我从列表中选择哪一项,最终显示在框中的项总是相同的。
有人能帮我解决这个问题吗?多谢!!!
这是我使用的代码:
Private Sub ComboBox1_Change()
Select Case ComboBox1.Text
Case "Een nieuwe start"
Case "Alles heeft zijn tijd"
Case "De wereld aan je voeten"
Case "Een levend boek"
Case "Drempels"
Case "Kerstmis"
Case "Confituur of choco"
Case "Hoe groot is de hemel?"
Case "Ongelovige Thomas"
Case "Feesten"
Case "Er is er één jarig!"
Case "Eén van hart"
Case "Ervoor gaan"
Case "Groen gras"
Case "RELatie"
Case "Vele plaatjes"
Case "Iedereen fan"
Case "Schattenjacht"
Case "Lichtbakens"
Case "Rijke Luis"
Case "Hemel op aarde"
Case "Op bezoek"
Case Else
End Select
End Sub
Private Sub UserForm1_Initialize()
ComboBox1.Clear
ComboBox1.AddItem "Een nieuwe start"
ComboBox1.AddItem "Alles heeft zijn tijd"
ComboBox1.AddItem "De wereld aan je voeten"
ComboBox1.AddItem "Een levend boek"
ComboBox1.AddItem "Drempels"
ComboBox1.AddItem "Kerstmis"
ComboBox1.AddItem "Confituur of choco"
ComboBox1.AddItem "Hoe groot is de hemel?"
ComboBox1.AddItem "Ongelovige Thomas"
ComboBox1.AddItem "Feesten"
ComboBox1.AddItem "Er is er één jarig!"
ComboBox1.AddItem "Eén van hart"
ComboBox1.AddItem "Ervoor gaan"
ComboBox1.AddItem "Groen gras"
ComboBox1.AddItem "RELatie"
ComboBox1.AddItem "Vele plaatjes"
ComboBox1.AddItem "Iedereen fan"
ComboBox1.AddItem "Schattenjacht"
ComboBox1.AddItem "Lichtbakens"
ComboBox1.AddItem "Rijke Luis"
ComboBox1.AddItem "Hemel op aarde"
ComboBox1.AddItem "Op bezoek"
ComboBox1.Text = ComboBox1.List(0)
End Sub
I'm having difficulties with a Combobox in a userform in an Excel document.
The combobox either doesn't appear in the userform, or the combobox remains blank, and when I enter any character in it, the list of items appears, but 2 or 3 times, instead of just once.
When I select an item, the chosen item doesn't appear in the box. It seems as if Excel^picks one at random, and whichever item I choose from the list, it's always the same one that ends up being displayed in the box.
Can anyone help me on this one? Thanks a lot!!!
This is the code I used:
Private Sub ComboBox1_Change()
Select Case ComboBox1.Text
Case "Een nieuwe start"
Case "Alles heeft zijn tijd"
Case "De wereld aan je voeten"
Case "Een levend boek"
Case "Drempels"
Case "Kerstmis"
Case "Confituur of choco"
Case "Hoe groot is de hemel?"
Case "Ongelovige Thomas"
Case "Feesten"
Case "Er is er één jarig!"
Case "Eén van hart"
Case "Ervoor gaan"
Case "Groen gras"
Case "RELatie"
Case "Vele plaatjes"
Case "Iedereen fan"
Case "Schattenjacht"
Case "Lichtbakens"
Case "Rijke Luis"
Case "Hemel op aarde"
Case "Op bezoek"
Case Else
End Select
End Sub
Private Sub UserForm1_Initialize()
ComboBox1.Clear
ComboBox1.AddItem "Een nieuwe start"
ComboBox1.AddItem "Alles heeft zijn tijd"
ComboBox1.AddItem "De wereld aan je voeten"
ComboBox1.AddItem "Een levend boek"
ComboBox1.AddItem "Drempels"
ComboBox1.AddItem "Kerstmis"
ComboBox1.AddItem "Confituur of choco"
ComboBox1.AddItem "Hoe groot is de hemel?"
ComboBox1.AddItem "Ongelovige Thomas"
ComboBox1.AddItem "Feesten"
ComboBox1.AddItem "Er is er één jarig!"
ComboBox1.AddItem "Eén van hart"
ComboBox1.AddItem "Ervoor gaan"
ComboBox1.AddItem "Groen gras"
ComboBox1.AddItem "RELatie"
ComboBox1.AddItem "Vele plaatjes"
ComboBox1.AddItem "Iedereen fan"
ComboBox1.AddItem "Schattenjacht"
ComboBox1.AddItem "Lichtbakens"
ComboBox1.AddItem "Rijke Luis"
ComboBox1.AddItem "Hemel op aarde"
ComboBox1.AddItem "Op bezoek"
ComboBox1.Text = ComboBox1.List(0)
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有
UserForm1_Initialize
,它永远不会被调用,它必须是UserForm_Initialize
(没有“1”)You have
UserForm1_Initialize
which will never get called, it must beUserForm_Initialize
(no "1")