-
Hey guys and gals -
I am working with an RTFText Box, and I need to make tag coloring for HTML elements such as: carrots (<, and >), equal signs with quotation marks (=""), and text that's in between the quotation marks (="text"). If anyone can help me out on this, I'd GREATLY appreciate it. Or, if anyone has a source code of it, I'd like that, too.
If you have these, reply on this forum, or EMAIL me at:
[email protected]
-
Your best friend will be the "instr" function.
To give you a mental image of what you want to do you will need to determine what "state" you are in at all times.
- Am I inside a TAG?
- Am I inside a string?
HTML follows some simple rules which state :
- When I encounter a < I MUST encounter a > somewhere on THIS line and the first one I find I will consider it to end the tag.
So therefor with each new line you can do :
Code:
If instr(NewLine,"<") > 0 Then
' You have found the start of a tag.
TagStart = instr(NewLine,"<")
TagEnd = instr(NewLine,">")
End If
NewTag = mid(NewLine,TagStart,TagEnd - TagStart +1)
Then with each tag you have you need to break it up into its individual "attributes". You know that directly following the "<" Will be the name of the tag and that this will continue until there is your first SPACE character. But the problem exists because you can put as many spaces as you like into HTML but it ignores them.
Code:
< A HREF ="test.html" TARGET= "_Parent" >
So you will have to watch out for them.
I could go on all day about the things you need to do but hopefully this has given you a starting point.
-
Thank you very much for your help... I'll try researching the "instr" command more in the MSDN Help for more ideas.
-
-
on http://www.codeguru.com/vb has a great working example too (also syntax colouring for VB code)
-
Thank you ssssoooo much people!!! Now I can finish my program! (yippie!) You guys have saved me a lot of time and effort, and I thank you very much for it.