Private Sub cmdDelete_Click() If lstv.ListItems.Count < 1 Then MsgBox "列表中没有项目!", vbCritical, "错误" Else If lstv.SelectedItem.Text = "" Then MsgBox "请选择一个项目!", vbCritical, "提示" Else msgbox "你选中" & lstv.SelectedItem.Text & "项目" End If End If End Sub
非常正确。其实MSDN中都可以看到。
if not lstv.SelectItem is Nothing then msgbox "选中某行"
Private Sub cmdDelete_Click()
If lstv.ListItems.Count < 1 Then
MsgBox "列表中没有项目!", vbCritical, "错误"
Else
If lstv.SelectedItem.Text = "" Then
MsgBox "请选择一个项目!", vbCritical, "提示"
Else
msgbox "你选中" & lstv.SelectedItem.Text & "项目"
End If
End If
End Sub