我在一个MDI工程里添加了一个别人程序里的窗体,作用是查找,替换,就像WORD里的那样,我希望它查找的对象是当前活动子窗体中richtextbox里的内容,其中查找的代码是:Private Sub CmdFind_Click()
If Me.Check1.Value = 0 Then
compare = vbBinaryCompare
Else
compare = vbTextCompare
End If
position = InStr(position + 1, frmframe.ActiveForm.rtftext.Text, Me.Text1.Text, compare)
If position > 0 Then
Me.CmdReplace.Enabled = True
frmframe.ActiveForm.rtftext.SelStart = position - 1
frmframe.ActiveForm.rtftext.SelLength = Len(Text1.Text)
Me.SetFocus
Else
MsgBox "未找到指定字符串"
Me.CmdReplace.Enabled = False
Me.SetFocus
End If
End Sub但是执行时总在position = InStr(position + 1, frmframe.ActiveForm.rtftext.Text, Me.Text1.Text, compare)处报错:实时错误426,只允许一个MDI窗体,可是frmframe就是当前工程里的 MDI窗体呀?我该怎么办呀?
If Me.Check1.Value = 0 Then
compare = vbBinaryCompare
Else
compare = vbTextCompare
End If
position = InStr(position + 1, frmframe.ActiveForm.rtftext.Text, Me.Text1.Text, compare)
If position > 0 Then
Me.CmdReplace.Enabled = True
frmframe.ActiveForm.rtftext.SelStart = position - 1
frmframe.ActiveForm.rtftext.SelLength = Len(Text1.Text)
Me.SetFocus
Else
MsgBox "未找到指定字符串"
Me.CmdReplace.Enabled = False
Me.SetFocus
End If
End Sub但是执行时总在position = InStr(position + 1, frmframe.ActiveForm.rtftext.Text, Me.Text1.Text, compare)处报错:实时错误426,只允许一个MDI窗体,可是frmframe就是当前工程里的 MDI窗体呀?我该怎么办呀?
If Me.Check1.Value = 0 Then
compare = vbBinaryCompare
Else
compare = vbTextCompare
End If
position = InStr(position + 1, frmframe.ActiveForm.rtftext.Text, Me.Text1.Text, compare)
If position > 0 Then
Me.CmdReplace.Enabled = True
me.ActiveForm.rtftext.SelStart = position - 1
me.ActiveForm.rtftext.SelLength = Len(Text1.Text)
Me.SetFocus
Else
MsgBox "未找到指定字符串"
Me.CmdReplace.Enabled = False
Me.SetFocus
End If
End Sub
看看可以了吧!