detect Richtextbox newline Visual basic

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'?

Answers


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:

For i = 1 To Len(rtext1.text)
  s = s & Asc(Mid(rtext1.text, i, 1)) & "  "
  Next i
MsgBox(s)

Need Your Help

Reschedule a job that was unscheduled in Quartz

java quartz-scheduler

I'm new to Quartz. Is it possible to reschedule a job that was unscheduled in Quartz?

How to wrap apex:columns in a div to use in slideToggle()

jquery salesforce apex-code visualforce jquery-slide-effects

I am trying to have a jquery slideToggle() function bound to a row of data in an apex:pageBlockTable.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.