先设置
text2.HideSelection
=false
这个需要在属性窗口设置
Private
Sub
Command1_Click()
Startme
=
Text2.SelLength
+
Text2.SelStart
+
1
'给变量赋值
Where2
=
InStr(Startme,
Text2.Text,
Text1.Text)
'令其从上次找到的地方找起
If
Where2
Then
Text2.SelStart
=
Where2
-
1
Text2.SelLength
=
Len(Text1.Text)
End
If
End
Sub
Private
Sub
Text1_Change()
If
InStr(Text2.Text,
Text1.Text)
>
0
Then
Text2.SelStart
=
InStr(Text2.Text,
Text1.Text)
-
1
Text2.SelLength
=
Len(Text1.Text)
End
If
End
Sub