还是直接上代码吧:Private Declare Function SendMessageByString& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String)Private Sub Command1_Click() Dim i&
'查找文本,全字匹配(字母不区分大小写),找到则移除项目 i = SendMessageByString(List1.hwnd, &H1A2, 0, Text1.Text) If (i >= 0) Then List1.RemoveItem i: exit sub MsgBox "没有找到该项目!", 64End Sub
纯 VB 方式 Option ExplicitPrivate Sub Command1_Click() Dim s As String Dim i As Long
s = Text1.Text For i = 0 To List1.ListCount - 1 If List1.List(i) = s Then List1.RemoveItem i Exit For End If Next End Sub
'查找文本,全字匹配(字母不区分大小写),找到则移除项目
i = SendMessageByString(List1.hwnd, &H1A2, 0, Text1.Text)
If (i >= 0) Then List1.RemoveItem i: exit sub
MsgBox "没有找到该项目!", 64End Sub
Option ExplicitPrivate Sub Command1_Click()
Dim s As String
Dim i As Long
s = Text1.Text
For i = 0 To List1.ListCount - 1
If List1.List(i) = s Then
List1.RemoveItem i
Exit For
End If
Next
End Sub