
关于VB listbox控件的问题
PrivateSubCommand4_Click()'查找地面物品按钮List1.ClearDimhpidAsLongDimjizhiAsLong'存储物品基地址Dimw...
Private Sub Command4_Click() '查找地面物品按钮
List1.Clear
Dim hpid As Long
Dim jizhi As Long '存储物品基地址
Dim wium As Long '物品数量
Dim base As Long '存储地址
Dim i As Integer '循环变量
Dim X As Long
Dim Y As Long
Dim s As String
Dim wpname_temp As Long '存放物品名的林时变量
Dim wpname(63) As Byte '存储物品名称
hpid = OpenProcess(PROCESS_ALL_ACCESS, 0, pid)
If hpid Then
ReadProcessMemory hpid, ByVal &H98A47C, jizhi, 4, 0
ReadProcessMemory hpid, ByVal jizhi + &H8, jizhi, 4, 0 '物品基址
ReadProcessMemory hpid, ByVal jizhi + &H28, wium, 4, 0 '得到物品数量
If wium <> 0 Then
For i = 0 To 768 '循环用来判断那个 值内 存在的物品
ReadProcessMemory hpid, ByVal wium + &H18, base, 4, 0
ReadProcessMemory hpid, ByVal base + i * 4, base, 4, 0 '从列表中选出地面上物品的地址
If base > 0 Then '判断是否存在物品
ReadProcessMemory hpid, ByVal base + 4, base, 4, 0
ReadProcessMemory hpid, ByVal base + &H164, wpname_temp, 4, 0
ReadProcessMemory hpid, ByVal wpname_temp, wpname(0), 64, 0 '得到物品名称
's = StrConv(wpname, vbUnicode)
List1.AddItem wpname
For X = 0 To List1.ListCount - 1
List1.ListIndex = X
If InStr(List1.List(X), wpname) <> 0 Then
Exit Sub
End If
Next X
List1.AddItem wpname
'For y = 0 To List2.ListCount - 1 '用循环查找是否是过滤表内要过滤的物品
'If InStr(wpname, List2.List(y)) > 0 Then '用InSet()进行对比,存在过滤表内容则过滤
'WriteProcessMemory hpid, ByVal base + &H110, 0, 4, 0 '变ID为0,有捡物品动作但背包内无此物品
'If List1.DataMember = List2.DataMember Then
'List1.RemoveItem (List1.DataMember)
'End If
End If
Next i
End If
End If
CloseHandle hpid
End Sub
大家好这是我写的一个显示地面物品的代码,显示出来在LISTBOX框里有重复的名字,如何过滤掉这些重复的名字呢?而且只能用Command跟LISTBOX实现.问题解决后可再追加50分.谢谢了
还有,如果list2上有的内容,如何让list1上不显示出来呢?????能给出相应的源码吗?wpname As Byte能跟list1.list(i)文本比较吗? 展开
List1.Clear
Dim hpid As Long
Dim jizhi As Long '存储物品基地址
Dim wium As Long '物品数量
Dim base As Long '存储地址
Dim i As Integer '循环变量
Dim X As Long
Dim Y As Long
Dim s As String
Dim wpname_temp As Long '存放物品名的林时变量
Dim wpname(63) As Byte '存储物品名称
hpid = OpenProcess(PROCESS_ALL_ACCESS, 0, pid)
If hpid Then
ReadProcessMemory hpid, ByVal &H98A47C, jizhi, 4, 0
ReadProcessMemory hpid, ByVal jizhi + &H8, jizhi, 4, 0 '物品基址
ReadProcessMemory hpid, ByVal jizhi + &H28, wium, 4, 0 '得到物品数量
If wium <> 0 Then
For i = 0 To 768 '循环用来判断那个 值内 存在的物品
ReadProcessMemory hpid, ByVal wium + &H18, base, 4, 0
ReadProcessMemory hpid, ByVal base + i * 4, base, 4, 0 '从列表中选出地面上物品的地址
If base > 0 Then '判断是否存在物品
ReadProcessMemory hpid, ByVal base + 4, base, 4, 0
ReadProcessMemory hpid, ByVal base + &H164, wpname_temp, 4, 0
ReadProcessMemory hpid, ByVal wpname_temp, wpname(0), 64, 0 '得到物品名称
's = StrConv(wpname, vbUnicode)
List1.AddItem wpname
For X = 0 To List1.ListCount - 1
List1.ListIndex = X
If InStr(List1.List(X), wpname) <> 0 Then
Exit Sub
End If
Next X
List1.AddItem wpname
'For y = 0 To List2.ListCount - 1 '用循环查找是否是过滤表内要过滤的物品
'If InStr(wpname, List2.List(y)) > 0 Then '用InSet()进行对比,存在过滤表内容则过滤
'WriteProcessMemory hpid, ByVal base + &H110, 0, 4, 0 '变ID为0,有捡物品动作但背包内无此物品
'If List1.DataMember = List2.DataMember Then
'List1.RemoveItem (List1.DataMember)
'End If
End If
Next i
End If
End If
CloseHandle hpid
End Sub
大家好这是我写的一个显示地面物品的代码,显示出来在LISTBOX框里有重复的名字,如何过滤掉这些重复的名字呢?而且只能用Command跟LISTBOX实现.问题解决后可再追加50分.谢谢了
还有,如果list2上有的内容,如何让list1上不显示出来呢?????能给出相应的源码吗?wpname As Byte能跟list1.list(i)文本比较吗? 展开
2个回答
展开全部
通常去掉重复都是从数据库读取的时候就过滤了,如果没有限制的话,也可以用循环来判断是否存在
temp=值
for i=0 to list1.listcount-1
if temp=list1.list(i) then
exit for
end if
next i
if i<>list1.listcount-1 then msgbox "列表1中己存在"
如果list2上有的内容,如何让list1,同样道理可以实现
temp=值
for i=0 to list1.listcount-1
if temp=list1.list(i) then
exit for
end if
next i
if i<>list1.listcount-1 then msgbox "列表1中己存在"
如果list2上有的内容,如何让list1,同样道理可以实现
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询