I have a program that open encrypted INI files (used in my other program as a settings).
In my Decrypt Exe (reading the INI file, decrypt it and able to edit the file and save as encrypted text). Other functionalities is
Find
.
My problem is sometimes the selected text when finish clicking the button
Find Text
is hidden by the
frmFind
. I want to set the position(top, left) when that happens. Many known application has this function.
Please Help... Thanks
This is my code in finding text, I don't know if there's a better solution on this
Dim startText As String
Dim endText As String
Dim findInt As Integer
Dim searchText As String
searchText = LCase(txtFind.Text)
If Option1.Value Then
startText = LCase(Left(frmDecrypt.RichTextBox1.Text, frmDecrypt.RichTextBox1.SelStart))
endText = LCase(Mid(frmDecrypt.RichTextBox1.Text, Len(startText)))
findInt = InStr(startText, searchText)
If findInt > 0 Then
frmDecrypt.RichTextBox1.SelStart = findInt - 1
frmDecrypt.RichTextBox1.SelLength = Len(searchText)
Else
frmFind.Visible = False
MsgBox "The specified region has been reach.", vbCritical
frmFind.Visible = True
End If
Else
startText = LCase(Left(frmDecrypt.RichTextBox1.Text, frmDecrypt.RichTextBox1.SelStart + frmDecrypt.RichTextBox1.SelLength))
endText = LCase(Mid(frmDecrypt.RichTextBox1.Text, Len(startText) + 1))
findInt = InStr(endText, searchText)
If findInt > 0 Then
frmDecrypt.RichTextBox1.SelStart = findInt + Len(startText) - 1
frmDecrypt.RichTextBox1.SelLength = Len(searchText)
Else
frmFind.Visible = False
MsgBox "The specified region has been reach.", vbCritical
frmFind.Visible = True
End If
End If
frmDecrypt.SetFocus