【发布时间】:2019-06-08 20:22:20
【问题描述】:
我在用户窗体中工作,并且正在对组合框进行编码。我使用.additem 在我的组合框中放置了一个下拉列表,每次用户按下列表中的一个项目时,都会出现一个消息框。
由于某种原因,我的第一个代码使消息框重新出现在组合框中的下一行,所以当按下第二行时,我有两个消息框而不是一个。
是因为and 函数吗?有没有其他方法可以做到这一点?
澄清一下,ComboBox1.ListIndex = 2(出现 2 个消息框,而我只需要我编码的那个)和 ComboBox1.ListIndex = 3(出现 3 个消息框而不是 1 个)。
If ComboBox1.ListIndex = 1 And Msgbox("Do you want to create a new company?", vbYesNo) = vbYes Then UserForm1.Show
If ComboBox1.ListIndex = 2 And Msgbox("Do you want to open the reports screen?", vbYesNo) = vbYes Then UserForm2.Show
If ComboBox1.ListIndex = 3 And Msgbox("Are you sure", vbYesNo) = vbYes Then Unload AccountsVbaPro
【问题讨论】: