📄 frmfindreplace.vb
字号:
Public Class frmFindReplace
Dim rtfEditor As RichTextBox = frmTextEditor.rtfEditor
Dim posisi As Integer = 0
Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
awal:
If chkMatchCase.Checked = False Then
rtfEditor.Find(txtFind.Text, posisi, rtfEditor.TextLength, RichTextBoxFinds.WholeWord)
Else
rtfEditor.Find(txtFind.Text, posisi, rtfEditor.TextLength, RichTextBoxFinds.MatchCase + RichTextBoxFinds.WholeWord)
End If
If posisi = rtfEditor.SelectionStart + txtFind.Text.Length Then
If MsgBox("Pencarian kembali dari awal document ?", MsgBoxStyle.OkCancel, "Ask") = MsgBoxResult.Ok Then
posisi = 0
GoTo awal
Else
Exit Sub
End If
Else
frmTextEditor.Select()
rtfEditor.Select(rtfEditor.SelectionStart, rtfEditor.SelectedText.Length)
posisi = rtfEditor.SelectionStart + txtFind.Text.Length
If MessageBox.Show("Apakah dilanjutkan pencarian?", Me.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification, False) = Windows.Forms.DialogResult.Cancel Then Exit Sub
End If
End Sub
Private Sub btnReplace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReplace.Click
awal:
frmTextEditor.Select()
rtfEditor.Select()
If chkMatchCase.Checked = False Then
rtfEditor.Find(txtFind.Text, posisi, rtfEditor.TextLength, RichTextBoxFinds.WholeWord)
Else
rtfEditor.Find(txtFind.Text, posisi, rtfEditor.TextLength, RichTextBoxFinds.MatchCase + RichTextBoxFinds.WholeWord)
End If
If posisi = rtfEditor.SelectionStart + txtFind.Text.Length Then
If MsgBox("Pencarian kembali dari awal document ?", MsgBoxStyle.OkCancel, "Ask") = MsgBoxResult.Ok Then
posisi = 0
GoTo awal
Else
Exit Sub
End If
Else
frmTextEditor.Select()
rtfEditor.Select(rtfEditor.SelectionStart, rtfEditor.SelectedText.Length)
If MessageBox.Show("Apakah diganti?", Me.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification, False) = Windows.Forms.DialogResult.OK Then rtfEditor.SelectedText = txtReplace.Text
posisi = rtfEditor.SelectionStart + txtFind.Text.Length
End If
End Sub
Private Sub btnReplaceAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReplaceAll.Click
awal:
If chkMatchCase.Checked = False Then
rtfEditor.Find(txtFind.Text, 0, rtfEditor.TextLength, RichTextBoxFinds.None)
Else
rtfEditor.Find(txtFind.Text, 0, rtfEditor.TextLength, RichTextBoxFinds.MatchCase + RichTextBoxFinds.None)
End If
If rtfEditor.SelectedText.Length > 0 Then
rtfEditor.SelectedText = txtReplace.Text
GoTo awal
End If
frmTextEditor.Select()
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Me.Close()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -