hehe,那这样来 num = 0 For i = 1 To InfoList.ListItems.Count If InfoList.ListItems(i).Selected = True Then num = num + 1 Next
If num > 1 Then Response = MsgBox("确实要删除这 " & num & " 项吗?", vbExclamation + vbYesNo, "询问") Else Response = MsgBox("确实要删除编号为 " & InfoList.SelectedItem & " 一项吗?", vbExclamation + vbYesNo, "询问") End If If Response = vbNo Then Exit Sub
rs.Open InfoTable, SYScnn, adOpenDynamic, adLockOptimistic i = 1 Do While i <= InfoList.ListItems.Count If InfoList.ListItems(i).Selected Then rs.Filter = "ID=" & InfoList.ListItems(i).Text rs.Delete rs.UpdateBatch adAffectAllChapters InfoList.ListItems.Remove i i = 0 End If i = i + 1 Loop
listview1.ListItems(i).Selected 属性 为true代表此行选择了
Private Sub Command2_Click() ListView1.ListItems.Add , , "1" ListView1.ListItems.Add , , "1" ListView1.ListItems.Add , , "1" ListView1.ListItems.Add , , "1" 'Set ListView1.SelectedItem = Nothing End SubPrivate Sub Command3_Click() Dim i As Integer Dim count As Integer
count = 0 For i = 1 To ListView1.ListItems.count If ListView1.ListItems(i).Selected Then count = count + 1 Combo1.AddItem ListView1.ListItems(i).Text & ":" & i End If Next
End Sub
dim sitem as listview.item dim sitemcount as long for each sitem in listview.ListItems if sitem.selected then sitemcount =sitemcount +1 next
问题换成,我要得到高亮化的总数和其中一个的值。
For i = 1 To InfoList.ListItems.Count
If InfoList.ListItems(i).Selected = True Then num = num + 1
Next
If num > 1 Then
Response = MsgBox("确实要删除这 " & num & " 项吗?", vbExclamation + vbYesNo, "询问")
Else
Response = MsgBox("确实要删除编号为 " & InfoList.SelectedItem & " 一项吗?", vbExclamation + vbYesNo, "询问")
End If
If Response = vbNo Then Exit Sub
rs.Open InfoTable, SYScnn, adOpenDynamic, adLockOptimistic
i = 1
Do While i <= InfoList.ListItems.Count
If InfoList.ListItems(i).Selected Then
rs.Filter = "ID=" & InfoList.ListItems(i).Text
rs.Delete
rs.UpdateBatch adAffectAllChapters
InfoList.ListItems.Remove i
i = 0
End If
i = i + 1
Loop
为true代表此行选择了
ListView1.ListItems.Add , , "1"
ListView1.ListItems.Add , , "1"
ListView1.ListItems.Add , , "1"
ListView1.ListItems.Add , , "1"
'Set ListView1.SelectedItem = Nothing
End SubPrivate Sub Command3_Click()
Dim i As Integer
Dim count As Integer
count = 0
For i = 1 To ListView1.ListItems.count
If ListView1.ListItems(i).Selected Then
count = count + 1
Combo1.AddItem ListView1.ListItems(i).Text & ":" & i
End If
Next
End Sub
dim sitemcount as long
for each sitem in listview.ListItems
if sitem.selected then sitemcount =sitemcount +1
next