Private Sub cmdFind1_Click()
On Error GoTo errorhandler:
Dim intFoundPos As Integer
strSearchFor = InputBox("Find what?", "Find")
If Not strSearchFor = "" Then
intFoundPos = InStr(1, Sheet5.txtBox1.Text, strSearchFor, 1)
intfoundpos2 = intFoundPos
strButtonPush = "Find"
Sheet5.txtBox1.Activate
End If
Exit Sub
errorhandler:
End Sub
Private Sub cmdFindNext1_Click()
Dim intFoundPos As Integer, intBegSearch As Integer
intBegSearch = intfoundpos2 + 2
intFoundPos = InStr(intBegSearch, Sheet5.txtBox1.Text, strSearchFor, 1)
If Not Len(strSearchFor) = 0 Then
intfoundpos2 = intFoundPos
strButtonPush = "FindNext"
Sheet5.txtBox1.Activate
End If
End Sub
Private Sub cmdReplace1_Click()
On Error GoTo errorhandler:
Dim intFoundPos As Integer, strReplace As String
Dim var As Variant
strSearchFor = InputBox("Find what?", "Find")
If Not strSearchFor = "" Then
intFoundPos = InStr(1, Sheet5.txtBox1.Text, strSearchFor, 1)
intfoundpos2 = intFoundPos
strButtonPush = "Replace"
Sheet5.txtBox1.Activate
End If
errorhandler:
End Sub
Private Sub txtBox1_GotFocus()
Const conBtns As Integer = vbOKOnly + vbInformation + vbDefaultButton1 + vbApplicationModal
Const conmsg As String = "The Search String was not found."
Dim intRetVal As Integer
Select Case strButtonPush
Case "Find"
'find
If intfoundpos2 = 0 Then
intRetVal = MsgBox(conmsg, conBtns, "Find")
Else
Sheet5.txtBox1.SelStart = intfoundpos2 - 1
Sheet5.txtBox1.SelStart = intfoundpos2 - 1 - Sheet5.txtBox1.CurLine
Sheet5.txtBox1.SelLength = Len(strSearchFor)
End If
Case "FindNext"
'find next
If intfoundpos2 = 0 Then
intRetVal = MsgBox(conmsg, conBtns, "Find Next")
Else
Sheet5.txtBox1.SelStart = intfoundpos2
Sheet5.txtBox1.SelStart = intfoundpos2 - 1 - Sheet5.txtBox1.CurLine
Sheet5.txtBox1.SelLength = Len(strSearchFor)
End If
Case "Replace"
'replace
If intfoundpos2 = 0 Then
intRetVal = MsgBox(conmsg, conBtns, "Find")
Else
Sheet5.txtBox1.SelStart = intfoundpos2
Sheet5.txtBox1.SelStart = intfoundpos2 - 1 - Sheet5.txtBox1.CurLine
Sheet5.txtBox1.SelLength = Len(strSearchFor)
strReplace = InputBox("Replace with what?", "Replace")
If strSearchFor = "" Then
Else
Sheet5.txtBox1.SelText = strReplace
End If
End If
Case Else
End Select
strButtonPush = ""
End Sub