Take the 2-minute tour ×

I am trying to create a programming editor using a rich text box in vb.net. It should change the color of text according to that text. For example, the keywords should be displayed in red, and numbers in blue. I can't find how to retrieve word by word from a rich text box .

share|improve this question
what have you tried? –  codingbiz Oct 3 '12 at 10:53
Show attempted solutions, and why they didn't work. –  cpp_prog Feb 19 at 17:44

4 Answers 4

I would do the following:

Dim txt as String = RichTextBox1.Text
Dim arr as String() = txt.Split(" "c) REM split along the whitespace character
For Each i In arr
    If IsNumeric(i) Then 
        REM change the color of the number to blue
Next i
share|improve this answer

You can use regular expressions to find the words, and another one for numbers. Try this website that well help you create your desired regular expressions http://regexpal.com/

share|improve this answer

I would just take the rich textbox text field and do a string split by space.

share|improve this answer

If you don't have to roll-your-own, the editors from SharpDevelop are easily extendable.

SharpDevelop3 uses SharpTextEditor(WinForms). SharpDevelop4 uses AvalonEdit (WPF)

share|improve this answer

Your Answer


