|
问题:
在已有数据的列表中如何实现按已知值来定位模糊搜索?(急急)
不知大家能否明白我说的意思。
请大家帮帮手。
我的不能解决方案为:
1、如何遍历整个列表框中的数据来匹配已知值:难点:如何将列表框的数据往下移?
2、如何排除已查的,继续点击按纽时往下查再定位?
难点:排除(设定静态数据??)
回答:(未验证):
源码如下:
private sub command78_click()
on error goto err_command78_click
dim lst as listbox
set lst = me.lstwlbm
if isnull(me.lstwlbm) then
lst.selected(0) = true
end if
'
dim listmax as integer
listmax = lst.listcount '+ lst.columnheads
if isnull(me.搜索) or ltrim(rtrim(me.搜索)) = "" then exit sub
dim strfind as string
static tmpsave as variant, ss as string
dim stid as variant, strfind1 as string, strind2 as string
dim i as integer, ii as integer
'strfind1 = "[" & treenaname & "] like '*" & me.搜索 & "*'"
strfind = me.搜索
if strfind <> tmpsave then '第一次搜索
ii = 0
else '此后每次的搜索(有无重复)
ii = lst.itemsselected.item(0) + 1
end if
for i = ii to lst.listcount - 1
if lst.itemdata(i) like "*" & strfind & "*" then
ii = i
lst.selected(ii) = true
me.recordset.findfirst "[itmid]='" & lst.itemdata(i) & "'"
me.bookmark = me.recordset.bookmark
exit for
end if
next i
if i = lst.listcount then
if msgbox("已全盘搜索过,找不到满足条件的记录!" & chr(10) & chr(13) & "要重头开始再查找吗?", vbcritical + vbyesno, "已搜索完毕!") = vbyes then tmpsave = ""
else
tmpsave = strfind
end if
exit_command78_click:
exit sub
err_command78_click:
msgbox err.description
resume exit_command78_click
end sub
|