'要试作此例,请在窗体中加入一个列表框和一个按钮,并且ListBox的Style设为1 - CheckBox '然后粘贴如下代码Private Sub Form_Load() List1.AddItem "aa" List1.AddItem "bb" List1.AddItem "cc" List1.AddItem "dd" List1.AddItem "ee" List1.AddItem "ff" End SubPrivate Sub Command1_Click() Dim lngIndex As Long
For lngIndex = 0 To List1.ListCount - 1 If List1.Selected(lngIndex) Then MsgBox List1.List(lngIndex) End If Next End Sub
to setfocus(脸谱) 你的理解能力也太那个了吧,老兄,我要用到LISTBOX 里的多项数据,这个LISTBOX已经填充完,比方这样说,现在LISTBOX里面有四项,我想在里面的两项前的CHECKBOX里打勾,选中后我要用打勾两项后面所对应的STRING值。
这还不简单吗? For i = 0 To Me.List1.ListCount If Me.List1.Selected(i) = True Then MsgBox Me.List1.List(i) End If Next 这不取到你要的了吗?
呵呵!原来是这样! Private Sub List1_ItemCheck(Item As Integer)Label1.Caption = List1.List(Item)
For I = 0 To List1.ListCount - 1
If List1.Selected(I) = True Then
'此条被选中
EndIf
Next I
我知道它是被选中了,可是我如果是选择的多条的话,我怎么把这几条的TEXT 一起返回呢,因为我要用这几条的TEXT
List1.AddItem "bbb"
List1.AddItem "ccc"
这样在这个控件中就有三个选项aaa,bbb,ccc了!
'然后粘贴如下代码Private Sub Form_Load()
List1.AddItem "aa"
List1.AddItem "bb"
List1.AddItem "cc"
List1.AddItem "dd"
List1.AddItem "ee"
List1.AddItem "ff"
End SubPrivate Sub Command1_Click()
Dim lngIndex As Long
For lngIndex = 0 To List1.ListCount - 1
If List1.Selected(lngIndex) Then
MsgBox List1.List(lngIndex)
End If
Next
End Sub
你的理解能力也太那个了吧,老兄,我要用到LISTBOX 里的多项数据,这个LISTBOX已经填充完,比方这样说,现在LISTBOX里面有四项,我想在里面的两项前的CHECKBOX里打勾,选中后我要用打勾两项后面所对应的STRING值。
For i = 0 To Me.List1.ListCount
If Me.List1.Selected(i) = True Then
MsgBox Me.List1.List(i)
End If
Next
这不取到你要的了吗?
Private Sub List1_ItemCheck(Item As Integer)Label1.Caption = List1.List(Item)
End Sub
这 下 你 该 满 足 了 吧!