Visual Basic 2005 编写 文本编辑器
“查找与替换”操作的“全部替换”功能的实现代码:
Private Sub bttnReplaceAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnReplaceAll.ClickDim curPos, curSel As IntegercurPos = TXTPadForm.TxtBox.SelectionStartcurSel = TXTPadForm.TxtBox.SelectionLengthTXTPadForm.TxtBox.Text = Replace(TXTPadForm.TxtBox.Text, Trim(searchWord.Text),Trim(replaceWord.Text))TXTPadForm.TxtBox.SelectionStart = curPosTXTPadForm.TxtBox.SelectionLength = curSelEnd Sub