Question Locked

How to do syntax highlighting with VB6

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

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?

3 replies

by don christner

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?

Don

This discussion is closed to new replies.