Results 1 to 6 of 6

Thread: HTML Color coding

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Location
    Perth, Australia
    Posts
    5

    Lightbulb HTML Color coding

    Ive been wanting to make a program that basically is a html editor. But i also want to make it with color coding.

    Any idea's?

    I had the idea of the Find method in the rich text box and search for "<" and ">" and the = and " in a HTML tag and change the SelectedColor and change the properties in a html tag. Like id and so on...
    The problem is with this is that when i type straight after the ">" or any other colored thingy the text will be that color
    and it looses focos of where i am typing it will loose focus.

    Does anyone know the code that they use in frontpage, ultradev, dreamweaver and visual studio that changes color of the text or any other good code.

    Plz help me. I am sorta newb

  2. #2
    Lively Member
    Join Date
    Aug 2002
    Location
    UK
    Posts
    70
    This was something i was playing with never took it anywhere. If you want more help just ask.

    You need to add reference to Microsoft VBScript Regular Expressions

    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3.     Dim regEx As New RegExp
    4.    
    5.     'regEx.Pattern = "(\<.*?\>).*?(\<\/.*?\>)"
    6.     regEx.Pattern = "\<.*?\>"
    7.     'regEx.Pattern = "<[^<>]+>"
    8.  
    9.     regEx.Global = True
    10.  
    11.     Set matches = regEx.Execute(rtbCode.Text)
    12.    
    13.     Dim match As match
    14.    
    15.     For Each match In matches
    16.         rtbCode.SelStart = match.FirstIndex
    17.         rtbCode.SelLength = match.Length
    18.         rtbCode.SelColor = colorMe(match.Value)
    19.         rtbCode.SelBold = True
    20.     Next
    21.  
    22.     colorSpeech
    23.  
    24. End Sub
    25.  
    26. Function colorSpeech()
    27.  
    28.     Dim regEx As New RegExp
    29.    
    30.     'regEx.Pattern = "(\<.*?\>).*?(\<\/.*?\>)"
    31.     regEx.Pattern = "\'.*?\'"
    32.     'regEx.Pattern = "<[^<>]+>"
    33.  
    34.     regEx.Global = True
    35.  
    36.     Set matches = regEx.Execute(rtbCode.Text)
    37.    
    38.     Dim match As match
    39.    
    40.     For Each match In matches
    41.         rtbCode.SelStart = match.FirstIndex
    42.         rtbCode.SelLength = match.Length
    43.         rtbCode.SelColor = &H8000& 'colorMe(match.Value)
    44.         rtbCode.SelBold = False
    45.     Next
    46.  
    47. End Function

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Location
    Perth, Australia
    Posts
    5
    I looked through the references and couldn't find a reference exactly the same as Microsoft VBScript Regular Expressions.

    But i did find Microsoft VBScript Regular Expressions 1.0
    and Microsoft VBScript Regular Expressions 5.5

    I added both and there is no type RegExp match and matches defined.

    Sorry i cant fix it myself but can u plz help me...again.

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Location
    Perth, Australia
    Posts
    5
    I looked through the references and couldn't find a reference exactly the same as Microsoft VBScript Regular Expressions.

    But i did find Microsoft VBScript Regular Expressions 1.0
    and Microsoft VBScript Regular Expressions 5.5

    I added both and there is no type RegExp match and matches defined.

    Sorry i cant fix it myself but can u plz help me...again.

  5. #5
    Lively Member
    Join Date
    Aug 2002
    Location
    UK
    Posts
    70
    You should only need one 5.5 I suggest a this should work unless they have changed the type for regexp in .net im only VB 6.

    You could try deleting the regexp bit and let vb fill it in for you.

  6. #6
    Lively Member
    Join Date
    Aug 2002
    Location
    UK
    Posts
    70
    Dont know if you can open VB6 projects in .Net but here is some code.

    Hope its useful
    Attached Files Attached Files

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