如果combobox是数组值,则填充备用comboboxVB​​A

如果combobox1表示“德国家庭购物”,如果给出以下数组,我有2个combobox在我的用户表单上

If ComboBox1.Value = "Germany Home Shopping" Then ComboBox2.List = Array("GER Singles ABE", "GER Singles CDF", "GER Small Cat ABE", "GER Small Cat CDF", "GER Small Cat All Zone", "GER Large Cat ABE", "GER Large Cat CDF", "GER Large Cat All Zone") End If 

我也想做相反的地方,如果值是combobox2中的数组答案之一,那么它会把德国家庭购物放在combobox1中。我认为这可以做到这一点?

 If ComboBox2.List = Array("GER Singles ABE", "GER Singles CDF", "GER Small Cat ABE", "GER Small Cat CDF", "GER Small Cat All Zone", "GER Large Cat ABE", "GER Large Cat CDF", "GER Large Cat All Zone") Then ComboBox1.Value = "Germany Home Shopping" End If 

但是,这似乎并没有为我工作。

在此先感谢:-)铝

你可以试试这个:

 Dim mylist mylist = Array("GER Singles ABE", "GER Singles CDF", "GER Small Cat ABE", _ "GER Small Cat CDF", "GER Small Cat All Zone", "GER Large Cat ABE", _ "GER Large Cat CDF", "GER Large Cat All Zone") If Not IsError(Application.Match(Me.ComboBox2.Value, mylist, 0)) Then Me.ComboBox1.Value = "Germany Home Shopping" End If