1.将字符串赋值于一个数组 2.做一个For i =1 to 数组上限 For j = 0 to list1.listcount-1 if list1.list(j)=数组(i) then list1.removeitem (list1.listindex) end if next j next i
你试试::Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd _ As Long, ByVal Msg As Long, wParam As Any, lParam As Any) As Long Public Const LB_GETCOUNT = &H18B Public Const LB_GETTEXT = &H189 Public Const LB_GETTEXTLEN = &H18APrivate Sub Command1_Click() Dim count As Long ' number of items in the list box Dim s2l As Long ' index of the second-to-last item Dim itemtext As String ' text of that item Dim textlen As Long ' length of the item text
count = SendMessage(List1.hWnd, LB_GETCOUNT, ByVal CLng(0), ByVal CLng(0)) For I= 1 To Count-1 textlen = SendMessage(List1.hWnd, LB_GETTEXTLEN, ByVal Cln(I), ByVal CLng(0)) itemtext = Space(textlen) & vbNullChar textlen = SendMessage(List1.hWnd, LB_GETTEXT, ByVal Clng(I), ByVal itemtext) itemtext = Left(itemtext, textlen) '进行你的判断 If itemtext = "你需要进行比较的字符串" Then Msgbox "OK,找到啦" Next End Sub'以上是 在网吧 临时 写的,没有测试 。 思路 谨供 参考 !
to sonicdater(发呆呆) 谢谢你,不过我是新手,还看不懂api,先copy , 等以后能看懂了再研究:)) to zlight68952() 请问要怎么把字符串付值与数组? dim shuzu(50) as string shuzu(1) = text1 shuzu(2) = text2 ………… shuzu(50)= text50 请问是这样的吗?
字符串写在文本文件中即可。 可以用文件操作读取。dim i as integeropen FileName for input as #1for i=1 to 50 input #1, shuzu(i) next然后再判断就行了。
Private Sub Command7_Click() Dim i As Integer Dim j As Integer Dim zifu As String Open "d:\123\yunxing.txt" For Input As #1 For i = 1 To 50 Line Input #1, zifu'错误提示:实时错误'62' 输入超出文件尾 For j = 0 To List1.ListCount - 1 If List1.List(j) = zifu Then List1.RemoveItem (j) End If Next j Next i End Sub 是那里错了?
Private Sub Command7_Click() Dim i As Integer Dim j As Integer Dim zifu(60) As String Open "d:\123\yunxing.txt" For Input As #1 For i = 1 To 50 Line Input #1, zifu(i)'错误提示:实时错误'62' 输入超出文件尾 For j = 0 To List1.ListCount - 1 If List1.List(j) = zifu(i) Then List1.RemoveItem (j) End If Next j Next i End Sub
搞定:))Private Sub Command7_Click() Dim i As Integer Dim j As Integer Dim zifu(70) As String Open "d:\123\yunxing.txt" For Input As #1 For i = 1 To 70 Do Until EOF(1) Line Input #1, zifu(i) For j = 0 To List1.ListCount - 1 If List1.List(j) = zifu(i) Then List1.RemoveItem (j) End If Next j Loop Next i Close #1 End Sub 谢谢大家帮忙,散分:)
2.做一个For i =1 to 数组上限
For j = 0 to list1.listcount-1
if list1.list(j)=数组(i) then
list1.removeitem (list1.listindex)
end if
next j
next i
As Long, ByVal Msg As Long, wParam As Any, lParam As Any) As Long
Public Const LB_GETCOUNT = &H18B
Public Const LB_GETTEXT = &H189
Public Const LB_GETTEXTLEN = &H18APrivate Sub Command1_Click()
Dim count As Long ' number of items in the list box
Dim s2l As Long ' index of the second-to-last item
Dim itemtext As String ' text of that item
Dim textlen As Long ' length of the item text
count = SendMessage(List1.hWnd, LB_GETCOUNT, ByVal CLng(0), ByVal CLng(0))
For I= 1 To Count-1
textlen = SendMessage(List1.hWnd, LB_GETTEXTLEN, ByVal Cln(I), ByVal CLng(0))
itemtext = Space(textlen) & vbNullChar
textlen = SendMessage(List1.hWnd, LB_GETTEXT, ByVal Clng(I), ByVal itemtext)
itemtext = Left(itemtext, textlen)
'进行你的判断
If itemtext = "你需要进行比较的字符串" Then Msgbox "OK,找到啦"
Next
End Sub'以上是 在网吧 临时 写的,没有测试 。 思路 谨供 参考 !
谢谢你,不过我是新手,还看不懂api,先copy , 等以后能看懂了再研究:))
to zlight68952()
请问要怎么把字符串付值与数组?
dim shuzu(50) as string
shuzu(1) = text1
shuzu(2) = text2
…………
shuzu(50)= text50
请问是这样的吗?
来个大虾帮忙看看。
可以用文件操作读取。dim i as integeropen FileName for input as #1for i=1 to 50
input #1, shuzu(i)
next然后再判断就行了。
Dim i As Integer
Dim j As Integer
Dim zifu As String
Open "d:\123\yunxing.txt" For Input As #1
For i = 1 To 50
Line Input #1, zifu'错误提示:实时错误'62' 输入超出文件尾
For j = 0 To List1.ListCount - 1
If List1.List(j) = zifu Then
List1.RemoveItem (j)
End If
Next j
Next i
End Sub
是那里错了?
Dim i As Integer
Dim j As Integer
Dim zifu(60) As String
Open "d:\123\yunxing.txt" For Input As #1
For i = 1 To 50
Line Input #1, zifu(i)'错误提示:实时错误'62' 输入超出文件尾
For j = 0 To List1.ListCount - 1
If List1.List(j) = zifu(i) Then
List1.RemoveItem (j)
End If
Next j
Next i
End Sub
Dim i As Integer
Dim j As Integer
Dim zifu(70) As String
Open "d:\123\yunxing.txt" For Input As #1
For i = 1 To 70
Do Until EOF(1)
Line Input #1, zifu(i)
For j = 0 To List1.ListCount - 1
If List1.List(j) = zifu(i) Then
List1.RemoveItem (j)
End If
Next j
Loop
Next i
Close #1
End Sub
谢谢大家帮忙,散分:)