В моей Winform пользователь выбирает переключатель. На основании этого переключателя он читает определенные строки из текстового файла. Затем я хочу, чтобы он искал апостроф, как только он найдет апостроф, я хочу, чтобы весь текст в строке после апострофа был зеленым (текст является реальным кодом, поэтому он должен окрашивать текст так же, как если бы он был были прокомментированы в компиляторе).
Вопрос: Как определить длину текста в строке после апострофа?
Вот мой код ...
Dim indexx As Integer = 0
Dim numOfChars As Integer
While indexx < RichTxtOut.Text.LastIndexOf("'")
numOfChars = 0
'This finds the char index of the first instance of what I am looking for.
Dim FoundCharIndex As Integer = RichTxtOut.Find("'", indexx, RichTxtOut.TextLength, RichTextBoxFinds.None)
'this finds the line the found char resides in
Dim LineOfFoundChar As Integer = RichTxtOut.GetLineFromCharIndex(FoundCharIndex)
Dim startCounting As Boolean = False
'count the number of characters after the apostrophe
For li As Integer = 0 To RichTxtOut.Lines(LineOfFoundChar).Count - 1
If RichTxtOut.Lines(LineOfFoundChar).Chars(li) = "'" Then
startCounting = True
End If
If startCounting Then numOfChars += 1
Next
RichTxtOut.Select(FoundCharIndex, numOfChars)
RichTxtOut.SelectionColor = Color.Green
numOfChars = 0
indexx = RichTxtOut.Text.IndexOf("'", indexx) + 1
End While