How to do syntax highlighting with VB6

By mastergamer ·
I am trying to make a code editor with VB6 for the language Lua.
I have opening and saving files done and working, but I cannot seem to get the syntax highlighting to work.
Meaning, I need to search for specific words, color them blue, and make them bold.

I have tried various ways with both normal Text Box's and Rich Text boxes, but I cannot seem to figure out how to go about doing it.

I was using Text1.Find("function") to look for the word function in a rich text box, and that worked, but I could not figure out how to then recolor it and or bold it. There is a RTB.SelBold and RTB.SelColor option, but that will replace "function" with whatever I type (I am trying to do this in Text1_Change())

Anyone have any thoughts? Suggestions? Any help to be provided in general?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -


by furevikstrand In reply to How to do syntax highligh ...
Collapse -

Selecting text

by Don Christner In reply to How to do syntax highligh ...

You will need to tell VB what text you want to change.

textbox1.SelStart = 0
textbox1.SelLength = Len(textbox1.Text)

will select all of the text within textbox1. If you want to select only part of the text, you'll have to use the Instr$ function.

If you're writing a code editor, would the code really be in a textbox?


Related Discussions

Related Forums