Private Sub Combo1_Click() Debug.Print Combo1.ListIndex Debug.Print Combo1.Text End Sub
VB中这样写 Combo1.List(nIndex),不用.text
也就是说我在改变combo列表时,在change事件中直接读就可以了,就是被选中的那项???
combo的change是内容文字改变,你指的应该是选中项改变吧,应该是click事件Private Sub Combo1_Click() Debug.Print Combo1.ListIndex Debug.Print Combo1.Text End Sub 就是当combo1选中项改变时,取得所选项的nIndex和Name
Debug.Print Combo1.ListIndex
Debug.Print Combo1.Text
End Sub
Combo1.List(nIndex),不用.text
Debug.Print Combo1.ListIndex
Debug.Print Combo1.Text
End Sub 就是当combo1选中项改变时,取得所选项的nIndex和Name
2、如何使Name和nIndex对应起来?
手工操作,添加的第一项是nIndex=0,第二项nIndex=1,余此类推......。
nIndex<Combo1.ListCount
3、如何根据nIndex得到Name?
用Combo1.List(Combo1.ListIndex)返回单击选择的项。