Private Sub Command1_Click() Dim pos As Long Static POS1 If Check1.Value = 1 Then pos = InStr(POS1 + 1, frmTips.Text1.Text, txtKey.Text, vbBinaryCompare) Else pos = InStr(POS1 + 1, frmTips.Text1.Text, txtKey.Text, vbTextCompare) End If POS1 = pos If pos > 0 Then If pos > 450 Then Me.Top = frmTips.Top + 1500 Else Me.Top = frmTips.Top + 4500 End If frmTips.Show frmTips.Text1.SelStart = pos - 1 frmTips.Text1.SelLength = Len(txtKey.Text) frmTips.Text1.SetFocus Else MsgBox "Nothing else found!" End If
End Sub
If InStr(Text2, Text1) > 0 Then Text2.SetFocus Text2.SelStart = InStr(Text2, Text1) - 1 Text2.SelLength = Len(Text1) Else MsgBox "没找到", vbInformation End If
Private Sub Command1_Click() s = InStr(Text2.Text, Text1.Text) If s Then Text2.SelStart = s - 1: Text2.SelLength = Len(Text1): Text2.SetFocus End Sub
Static POS1
If Check1.Value = 1 Then
pos = InStr(POS1 + 1, frmTips.Text1.Text, txtKey.Text, vbBinaryCompare)
Else
pos = InStr(POS1 + 1, frmTips.Text1.Text, txtKey.Text, vbTextCompare)
End If
POS1 = pos
If pos > 0 Then
If pos > 450 Then
Me.Top = frmTips.Top + 1500
Else
Me.Top = frmTips.Top + 4500
End If
frmTips.Show
frmTips.Text1.SelStart = pos - 1
frmTips.Text1.SelLength = Len(txtKey.Text)
frmTips.Text1.SetFocus
Else
MsgBox "Nothing else found!"
End If
End Sub
If InStr(Text2, Text1) > 0 Then
Text2.SetFocus
Text2.SelStart = InStr(Text2, Text1) - 1
Text2.SelLength = Len(Text1)
Else
MsgBox "没找到", vbInformation
End If
s = InStr(Text2.Text, Text1.Text)
If s Then Text2.SelStart = s - 1: Text2.SelLength = Len(Text1): Text2.SetFocus
End Sub