Results 1 to 6 of 6

Thread: HTML Tag Coloring, anyone?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Posts
    16

    Arrow

    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]
    Webmaster Czaries
    http://www1.50megs.com/css

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    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.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Posts
    16

    Lightbulb

    Thank you very much for your help... I'll try researching the "instr" command more in the MSDN Help for more ideas.
    Webmaster Czaries
    http://www1.50megs.com/css

  4. #4
    Lively Member
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    84

    Smile

    Why don't you have a look at this:

    http://www.vbweb.co.uk/code/downloads/colortag.zip
    or
    http://www.vbweb.co.uk/code/downloads/htmlcolour.zip

    It's from http://www.vbweb.co.uk
    section : Text Editing & Strings

    Hope this helps

  5. #5
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386
    on http://www.codeguru.com/vb has a great working example too (also syntax colouring for VB code)
    Hope this helps

    Crazy D

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Posts
    16

    Lightbulb

    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.
    Webmaster Czaries
    http://www1.50megs.com/css

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width