列表框蓝色(被选中状态)事件??
列表框中记录如下:
11
12
13
14
15
16
17
18
19
20
窗体运行时,列表框蓝色(被选中状态)是在最后一条记录上。
自定义记录条数为x.
最后一条记录为起始值1,即x = 1。
向上一条记录则x = x + 1。
那么当我点击列表框中的“18”时(被选中状态),就是x = 3。
这个代码应该怎样写呢?
请写出代码来,谢谢!
[解决办法]
你要的x应该就是List1.ListCount - List1.ListIndex
[解决办法]
- VB code
Private Sub Form_Load() Dim i As Integer For i = 11 To 20 List1.AddItem i List1.ItemData(i - 11) = 21 - i Next List1.ListIndex = List1.ListCount - 1End SubPrivate Sub List1_Click() Dim x As Integer x = List1.ItemData(List1.ListIndex) Debug.Print xEnd Sub