Combo控件引用ItemData()时出错。请求各位解答
'两个Combo控件,一个text控件。网上找不到答案,才求助各位Private Sub Combo1_Click()
Print Combo1.ItemData(Combo1.ListIndex) '引用正常
Print Combo2.ItemData(Combo2.ListIndex) '错误!!提示无效属性数组索引。 为什么Combo1可以,Combo2不可以??
Text1.Text = Combo1.ItemData(Combo1.ListIndex) + Combo2.ItemData(Combo2.ListIndex) '单击选择Combo1时计算和并用Text1控件显示。出错!
End Sub
Private Sub Form_Load()
Combo1.AddItem "a": Combo1.ItemData(0) = 100
Combo1.AddItem "b": Combo1.ItemData(1) = 200
Combo1.AddItem "c": Combo1.ItemData(2) = 300
Combo1.ListIndex = 0
Combo2.AddItem "a": Combo2.ItemData(0) = 400
Combo2.AddItem "b": Combo2.ItemData(1) = 500
Combo2.AddItem "c": Combo2.ItemData(2) = 600
Combo2.ListIndex = 1
Show
Print Combo1.ItemData(Combo1.ListIndex) '此处引用ItemData()值正常
Print Combo2.ItemData(Combo2.ListIndex)
End Sub
[ 本帖最后由 i89586 于 2011-9-29 16:07 编辑 ]