vb.net获取richtextbox中查找单词的行号

vb.net获取richtextbox中查找单词的行号,vb.net,richtextbox,syntax-highlighting,Vb.net,Richtextbox,Syntax Highlighting,有没有办法获取richtextbox中突出显示的单词的行号这是在richtextbox中突出显示文本的代码 Dim len As Integer = txtMbox.TextLength For Each word As String In MisSpelledList Dim lastindex = txtMbox.Text.LastIndexOf(word) Dim index As Integer = 0 While index

有没有办法获取richtextbox中突出显示的单词的行号这是在richtextbox中突出显示文本的代码

Dim len As Integer = txtMbox.TextLength
    For Each word As String In MisSpelledList

        Dim lastindex = txtMbox.Text.LastIndexOf(word)
        Dim index As Integer = 0

        While index < lastindex

            txtMbox.Find(word, index, len, RichTextBoxFinds.None)

            txtMbox.SelectionBackColor = Color.Red


            index = txtMbox.Text.IndexOf(word, index) + 1


        End While
比如说

  i am  *doing code for *practice 
  this is very hard *language 
  its very *good day
带有(*)标记的单词表示突出显示的单词

我想出去

第一行:做什么 第1行:实践 第2行:语言 第三行:好的

这是我用来突出显示richtextbox中的单词的代码

Dim len As Integer = txtMbox.TextLength
    For Each word As String In MisSpelledList

        Dim lastindex = txtMbox.Text.LastIndexOf(word)
        Dim index As Integer = 0

        While index < lastindex

            txtMbox.Find(word, index, len, RichTextBoxFinds.None)

            txtMbox.SelectionBackColor = Color.Red


            index = txtMbox.Text.IndexOf(word, index) + 1


        End While
Dim len As Integer=txtMbox.TextLength
对于拼写错误列表中的字符串形式的每个单词
Dim lastindex=txtMbox.Text.LastIndexOf(word)
作为整数的Dim索引=0
而index
用户是否会输入“*”?实际上,我在这个问题中使用了*标记来显示突出显示的单词。在实际程序中,单词会以红色背景突出显示,您可以为每个脏话创建一个语句,并在键入单词时生成一个布尔值。将其全部传递到if语句中。您可以通过两种方式来执行此操作,在设置单词的
背景色的部分,将位置(索引)和单词存储在
数组中或
列表中等,然后在需要行号时使用
YourRichTextBox.GetLineFromCharIndex(索引)