7,785
社区成员




Const LB_ADDSTRING = &H180
Const LB_FINDSTRING = &H18F
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Dim lngIndex As Long
Dim strItem As String
strItem = "这个变量等于你要插入到ListBox中的值"
lngIndex = SendMessage(List1.hWnd, LB_FINDSTRING, -1, ByVal strItem) '这里设置-1,是表示从头开始查找
If lngIndex = -1 Then '等于-1则表示没有找到匹配项目
SendMessage List1.hWnd, LB_ADDSTRING, 0, ByVal strItem '增加项目到ListBox中
End If
Const LB_FINDSTRINGEXACT = &H1A2