vb.关于richtextbox查找替换
来源:百度知道 编辑:UC知道 时间:2024/09/21 18:19:18
Dim strFind As String '定义一个查找字符
Dim intStart As Integer '定义找到位置
Dim strReplace As String '定义替换的字符
Dim strFindOn As String '查找和查找下一处
Private Sub cmdReplaceAll_click()
Dim intCont As Integer
If txtFind.Text = "" Then
lblPrint.Caption = "请先输入查找关键字..."
Exit Sub
Else
strFind = txtFind.Text
strReplace = txtReplace
If strFind <> strReplace Then
Do While intStart >= 0
intStart = frmWordPad.RichText.Find(strFind)
If intStart >= 0 Then
frmWordPad.RichText.SelStart = intStart
frmWordPad.RichText.SelLength = Len(strFind)
Dim intStart As Integer '定义找到位置
Dim strReplace As String '定义替换的字符
Dim strFindOn As String '查找和查找下一处
Private Sub cmdReplaceAll_click()
Dim intCont As Integer
If txtFind.Text = "" Then
lblPrint.Caption = "请先输入查找关键字..."
Exit Sub
Else
strFind = txtFind.Text
strReplace = txtReplace
If strFind <> strReplace Then
Do While intStart >= 0
intStart = frmWordPad.RichText.Find(strFind)
If intStart >= 0 Then
frmWordPad.RichText.SelStart = intStart
frmWordPad.RichText.SelLength = Len(strFind)
去掉Replace
最简单
将
lblPrint.Caption = "请先输入查找关键字..."
Exit Sub
Else
strFind = txtFind.Text
strReplace = txtReplace
If strFind <> strReplace Then中的
strFind = txtFind.Text
strReplace = txtReplace 改成
strReplace = txtFind.Text
就是替换的还是原来的