CodeColorer

On JP’s recommendation I’m trying CodeColorer for syntax highlighting.

Public Sub LoadFromFile()
   
    Dim xmlDoc As MSXML2.DOMDocument
    Dim xmlNodes As MSXML2.IXMLDOMNodeList
    Dim xmlNode As MSXML2.IXMLDOMNode
    Dim i As Long
    Dim clsRandom As CRandom
   
    Set xmlDoc = New MSXML2.DOMDocument
    xmlDoc.Load Environ(“USERPROFILE”) & “My DocumentsMy DropboxwcdkSampleData.xml”
    Set xmlNodes = xmlDoc.documentElement.selectNodes(“//SampleDatum”)
   
    For i = 0 To xmlNodes.Length – 1
        Set xmlNode = xmlNodes.Item(i)
        Set clsRandom = New CRandom
       
        clsRandom.RandType = xmlNode.selectSingleNode(“RandType”).nodeTypedValue
        clsRandom.Name = xmlNode.selectSingleNode(“Name”).nodeTypedValue
        clsRandom.Min = xmlNode.selectSingleNode(“Min”).nodeTypedValue
        clsRandom.Max = xmlNode.selectSingleNode(“Max”).nodeTypedValue
        clsRandom.Decimals = xmlNode.selectSingleNode(“Decimals”).nodeTypedValue
        clsRandom.Sequential = xmlNode.selectSingleNode(“Sequential”).nodeTypedValue
        clsRandom.Skip = xmlNode.selectSingleNode(“Skip”).nodeTypedValue
        Me.Add clsRandom
       
    Next i
End Sub

When I installed it, it said that there was a conflict with my existing highlighter. I was hoping that I wouldn’t have to disable the old one because it will make my existing code look ugly. I suppose I could do an update query on all the old posts. Sounds dangerous.

18 Comments

  1. Well, the code looks good. How about in the comments?

    Sub test()
       
        If 1 > 2 Then
            ‘do something
       ElseIf 1 < 2 Then
            Exit Sub
        Else
            MsgBox “this” & “that”
        End If
       
    End Sub
  2. Wow, greater than, less than and ampersands! Here’s how you do it:

    <code lang=”vb”>Code goes here</code>

  3. Michael says:

    Good morning, Dick -

    Testing “not equals”

    Function baseconv(InputN, BaseN)
    ‘http://support.microsoft.com/kb/135635
      Dim quotient, remainder As Single
       Dim Answer As String
       quotient = InputN   ‘ Set quotient to number to convert.
      remainder = InputN  ‘ Set remainder to number to convert.
      Answer = “”
     
       Do While quotient <> 0   ‘ Loop while quotient is not zero.
         remainder = quotient Mod BaseN
          quotient = Int(quotient / BaseN)
          Answer = remainder & Answer
       Loop
       baseconv = Val(Answer)   ‘ Convert answer variable to a number.

    End Function

    …mrt

  4. JP says:

    Just get a search and replace plugin (i.e. http://wordpress.org/extend/plugins/search-and-replace/) and replace “

    ” with the new opening tag in comments and posts. Replace “

    ” with the closing tag, and you should be set.

  5. JP says:

    Ugh, WordPress mangled my comment. But you get the idea: Replace the original opening code tag with the new one (in comments and posts), and replace the closing code tag with the new closing tag.

  6. Jon Peltier says:

    When I started my blog I tried a few code formatters, but I couldn’t find one that didn’t totally suck. I’ve reverted to using <pre> tags around code, and unless I specifically highlight a keyword or line of code by hand, it’s all monochromatic.

    This CodeColorer thing looks pretty good.

  7. Michael says:

    Dick -

    What is your VBE font? and what’s above?

    I’ve run with Courier New so long, it may be time for a change ;-)

    …mrt

  8. Dick,

    This look very good to me :)

    We, who use WordPress’s blogspace, use another plug-in and it has row lines (see http://xldennis.wordpress.com/2009/10/17/install-and-activate-add-ins-in-excel-with-visual-installer/). But I would like to have this kind of coloring too.

    Kind regards,
    Dennis

  9. I really like that I can use code tags with this. Correct me if I’m wrong, but if I get rid of this plug in, all my code will revert to normal code tag formatting, which is better than plain text.

  10. JP says:

    You’re correct, Dick, see http://codex.wordpress.org/Writing_Code_in_Your_Posts

    Although I couldn’t say what the ” lang=”vb” ” part would do.

  11. Micheal: I like Courier New the best because it looks like the VBE, so I change the plugin to use it. It was Monaco/Lucida Console prior to that.

  12. Michael says:

    Dick -

    Looks great! Don’t have to worry about blank lines, too! An added benny.

    …mrt

  13. JP says:

    Dennis: CodeColorer can do line numbers as well.

  14. Doug Jenkins says:

    Dennis – where do you get the WordPress code plug-in? Does it handle the dreaded greter than and less than symbols and comment markers properly?

  15. JP says:

    Doug – you can’t use plugins with wordpress.com-hosted blogs.

  16. mark nold says:

    Dick,

    Have a look at Prettify JS – http://code.google.com/p/google-code-prettify/

    I’ve written a short blurb on getting it work with VB/VBA code – http://officeadd.in/code/prettify_js_-_syntax_highlighting.aspx

    The main reason why I suggest is that it’s simple and Stackoverflow use it very successfully.

  17. Doug,

    I will let you know as soon as I have fully tested it.

    Kind regards,
    Dennis

  18. [...] Twitter, Dick Kusleika said that he’s using CodeColorer too, and it works well. I decided to test the plug-in here, before installing it on the Contextures [...]

Posting code or formulas in your comment? Use <code> tags!

  • <code lang="vb">Block of code goes here</code>
  • <code lang="vb" inline="true">Inline code goes here</code>
  • <code>Formula goes here</code>

Leave a Reply

You must be logged in to post a comment.

Here's how to update your reports of company and nearly any web data: