高级记事本父窗体与子窗体的运用

qq_38853847 2017-05-21 10:46:14
记事本一次可以打开多个文本,可以在父窗体中打开多个子窗体
如Dim frm1 As New Form2
我编的码可以同时打开多个窗口,但无法在窗口中完成替换的功能
这是替换的代码
Dim cz As String = TextBox1.Text
If cz.Length <= 0 Then
MessageBox.Show("请输入要查的内容!")
Return
End If

If chushiweizhi <> 0 Then
frm1.RichTextBox1.SelectionColor = frm1.RichTextBox1.SelectionColor
End If

If chushiweizhi + cz.Length > frm1.RichTextBox1.TextLength Then

MessageBox.Show("已经达文件尾, 是否从文件头开始搜索?", "查找", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If

Dim pos As Integer
pos = frm1.RichTextBox1.Find(cz, chushiweizhi, RichTextBoxFinds.MatchCase)
If pos >= 0 Then
frm1.RichTextBox1.SelectionStart = pos
frm1.RichTextBox1.SelectionLength = cz.Length()
previouscolor = frm1.RichTextBox1.SelectionColor
frm1.RichTextBox1.Text = frm1.RichTextBox1.Text.Replace(TextBox1.Text, TextBox3.Text)
chushiweizhi = pos + cz.Length()
Else
MessageBox.Show("未找到指定的文本", "查找")
End If
单独拿出来,可以用,但用到这里,会发现frm1.richtextbox1无法传递过来
始终是0
跪求大佬讲解解决办法
...全文
201 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
threenewbee 2017-05-22
  • 打赏
  • 举报
回复
this.ActiveMdiChild得到当前窗口,再获取richtextbox
qq_38853847 2017-05-22
  • 打赏
  • 举报
回复
是这样写吗this.ActiveMdiChild.richtextbox 还是get this.ActiveMdiChild() frm1.richtextbox?
qq_38853847 2017-05-22
  • 打赏
  • 举报
回复
引用 1 楼 caozhy的回复:
this.ActiveMdiChild得到当前窗口,再获取richtextbox
是这样写吗this.ActiveMdiChild.richtextbox<br /> 还是get this.ActiveMdiChild()    frm1.richtextbox?

16,553

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧