
) Dim words As List(Of String) = New List(Of String)(New String() {"AddHandler", _
"AddressOf", _
"Alias", _
"And", _
"AndAlso", _
"Ansi", _
"As", _
"Assembly", _
" Auto", _
"Boolean", _
"ByRef", _
"Byte", _
"ByVal", _
"Call", _
"Case", _
"Catch", _
"CBool", _
"CByte", _
"CChar", _
"CDate", _
"CDec", _
"CDbl", _
"Char", _
"CInt", _
"Class", _
"CLng", _
"CObj", _
"Const", _
"CShort", _
"CSng", _
"CStr", _
"CType", _
"Date", _
"Decimal", _
"Declare", _
"Default", _
"Delegate", _
"Dim", _
"DirectCast", _
"Do", _
"Double", _
"Each", _
"Else", _
"ElseIf", _
"End", _
"Enum", _
"Erase", _
"Error", _
"Event", _
"Exit", _
"False", _
"Finally", _
"For", _
"Friend", _
"Function", _
"Get", _
"GetType", _
"GoSub", _
"GoTo", _
"Handles", _
"If", _
"Implements", _
"Imports", _
"In", _
"Inherits", _
"Integer", _
"Interface", _
"Is", _
"Let", _
"Lib", _
"Like", _
"Long", _
"Loop", _
"Me", _
"Mod", _
"Module", _
"MustInherit", _
"MustOverride", _
"MyBase", _
"MyClass", _
"Namespace", _
"New", _
"Next", _
"Not", _
"Nothing", _
"NotInheritable", _
"NotOverridable", _
"Object", _
"On", _
"Option", _
"Optional", _
"Or", _
"OrElse", _
"Overloads", _
"Overridable", _
"Overrides", _
"ParamArray", _
"Preserve", _
"Private", _
"Property", _
"Protected", _
"Public", _
"RaiseEvent", _
"ReadOnly", _
"ReDim", _
"REM", _
"RemoveHandler", _
"Resume", _
"Return", _
"Select", _
"Set", _
"Shadows", _
"Shared", _
"Short", _
"Single", _
"Static", _
"Step", _
"Stop", _
"String", _
"Structure", _
"Sub", _
"SyncLock", _
"Then", _
"Throw", _
"To", _
"True", _
"Try", _
"TypeOf", _
"Unicode", _
"Until", _
"Variant", _
"When", _
"While", _
"With", _
"WithEvents", _
"WriteOnly", _
"Xor", _
"#Const", _
"#ExternalSource", _
"#If...Then...#Else", _
"#Region"})
If The Richtextbox contains any of the list above then change color to blue
If RichTextBox1.Text.Length > 0 Then
Dim selectStart As Integer = RichTextBox1.SelectionStart
RichTextBox1.Select(0, RichTextBox1.Text.Length)
RichTextBox1.SelectionColor = Color.Black
RichTextBox1.DeselectAll()
For Each oneWord As String In words
Dim pos As Integer = 0
Do While RichTextBox1.Text.ToUpper.IndexOf(oneWord.ToUpper, pos) >= 0
pos = RichTextBox1.Find(oneWord.ToUpper, RichTextBoxFinds.WholeWord)
RichTextBox1.Select(pos, oneWord.Length)
RichTextBox1.SelectionColor = Color.Blue
pos += 1
Loop
Next
RichTextBox1.SelectionStart = selectStart
RichTextBox1.SelectionLength = 0
End If

Dim rx As New Regex("AddHandler |AddressOf |Alias |And |AndAlso |Ansi |As |Assembly |Auto |Boolean |ByRef |Byte |" + _
"ByVal |Call |Case |Catch |CBool |CByte |CChar |CDate |CDec |CDbl |Char |CInt |Class |CLng |CObj |Const |CShort |CSng |" + _
"CStr |CType |Date |Decimal |Declare |Default |Delegate |Dim |DirectCast |Do |Double |Each |Else |ElseIf |End |Enum |" + _
"Erase |Error |Event |Exit |False |Finally |For |Friend |Function |Get |GetType |GoSub |GoTo |Handles |If |Implements |Imports |" + _
"In |Inherits |Integer |Interface |Is |Let |Lib |Like |Long |Loop |Me |Mod |Module |MustInherit |MustOverride |MyBase |" + _
"MyClass |Namespace |New |Next |Not |Nothing |NotInheritable |NotOverridable |Object |On |Option |Optional |Or |OrElse |" + _
"Overloads |Overridable |Overrides |ParamArray |Preserve |Private |Property |Protected |Public |RaiseEvent |ReadOnly |ReDim |" + _
"REM |RemoveHandler |Resume |Return |Select |Set |Shadows |Shared |Short |Single |Static |Step |Stop |String |Structure |Sub |" + _
"SyncLock |Then |Throw |To |True |Try |TypeOf |Unicode |Until |Variant |When |While |With |WithEvents |WriteOnly |Xor |#Const |#ExternalSource |#If...Then...#Else |#Region |")
For Each m As Match In rx.Matches(RichTextBox1.Text)
RichTextBox1.SelectionStart = m.Index
RichTextBox1.SelectionLength = m.Value.Length
RichTextBox1.SelectionColor = Color.Blue
Next
rx = New Regex(""".+""")
For Each m As Match In rx.Matches(RichTextBox1.Text)
RichTextBox1.SelectionStart = m.Index
RichTextBox1.SelectionLength = m.Value.Length
RichTextBox1.SelectionColor = Color.Tomato
Next
If paste function occured then generate the second code esle generate the first code