troubleshooting Question

Source Code Coloring in a richtextbox control In vb 2008

Avatar of vickjam
vickjam asked on
Visual Basic ClassicVisual Basic.NET
2 Comments1 Solution220 ViewsLast Modified:
I have a richtextbox control that I am using to show html tags inside and I want to have the tags color set to blue. Anything within quotation marks I want green. I wrote this little case statement below and it works except for the last charater in the tag or quote always resorts to black. Is there a better way to accomplish this or do I need to edit this case statement. Maybe if you start a project with a richtextbox control and try this out you will see what I mean. I have declared Public Charcount as boolean = false at the top of the form.
Private Sub RichTextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyDown
        Select Case (e.KeyCode)
            Case Is = 188 'This is the "<" Key
                RichTextBox1.SelectionColor = Color.Navy
            Case Is = 190 'This is the ">" Key
                RichTextBox1.SelectionColor = Color.Navy
                RichTextBox1.SelectionColor = Color.Black
            Case Is = 222 And Charcount = False ' This is the """" Key
                Charcount = True
                RichTextBox1.SelectionColor = Color.Green
            Case Is = 222 And Charcount = True
                Charcount = False
                RichTextBox1.SelectionColor = Color.Black
        End Select
    End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros