vb制作记事本如何实现查找下一个的功能?

来源:百度知道 编辑:UC知道 时间:2024/06/30 00:34:51
我用的是TEXTBOX,我的查找代码如下,只能查找一次:
On Error Resume Next
Dim a, b, c As String
b = Form1.Text1.Text
c = Form2.Text2.Text
a = InStr(b, c)
Form1.Text1.SelStart = a - 1
Form1.Text1.SelLength = Len(c)
Form1.Show
我要写论文啊,大家帮帮我,谢谢!

dim sFind as string, lastPos

private sub Find_Click()
on error resume next
sFind=text2.text
lastPos=instr(0,text1.text,sFind)
if lastPos<>-1 then
text1.selstart=lastPos-1
text1.sellength=len(sFind)
end if
end sub

private sub FindNext_Click()
on error resume next
if sFind="" or lastPos=-1 then exit sub
lastPos=instr(lastPos,text1.text,sFind)
if lastPos<>-1 then
text1.selstart=lastPos-1
text1.sellength=len(sFind)
end if
end sub

dim sFind as string, lastPos

private sub Find_Click()
on error resume next
sFind=text2.text
lastPos=instr(0,text1.text,sFind)
if lastPos<>-1 then
text1.selstart=lastPos-1
text1.sellength=len(sFind)
end if
end sub

private sub FindNext_Click()
on error resume next
if sFind="" or lastPos=-1 then exit sub
lastPos=ins