|
-
Apr 12th, 2000, 07:33 AM
#1
Thread Starter
Junior Member
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]
-
Apr 12th, 2000, 07:44 AM
#2
Hyperactive Member
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.
-
Apr 13th, 2000, 06:21 AM
#3
Thread Starter
Junior Member
Thank you very much for your help... I'll try researching the "instr" command more in the MSDN Help for more ideas.
-
Apr 13th, 2000, 02:24 PM
#4
Lively Member
-
Apr 13th, 2000, 03:17 PM
#5
Hyperactive Member
on http://www.codeguru.com/vb has a great working example too (also syntax colouring for VB code)
-
Apr 14th, 2000, 10:09 AM
#6
Thread Starter
Junior Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|