i’m creating a RichTextBox with Syntax-Highlighting, my actual code can check for words that are separated from other words with space or with nothing with that statement:
If RichTextBox1.SelectedText = " " Or RichTextBox1.SelectedText = Nothing Then
So when i type “test” (my highlighted word) on the RichTextBox it gets blue, it works on all cases, exept when i type “test”, it gets blue, then i press enter, it gets black again, like if there is a character after the word.
I guess that the newline is represented by a character on the RichTextBox and thats why its not getting reconized only as “test”, so whats the character i had to put on the if so it can check?
i tried this way:
If RichTextBox1.SelectedText = "\n" Then
and:
If RichTextBox1.SelectedText = VbNewLine Then
but both didnt work, Anyone knows the character that means ‘its a new line here’?
It’s a chr(10), a linefeed character. You can also use RichTextBox1.Lines if you want to handle each line separately.
Here’s one way to look at single-byte characters in a RichTextBox: