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
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.
Well, the code looks good. How about in the comments?
If 1 > 2 Then
‘do something
ElseIf 1 < 2 Then
Exit Sub
Else
MsgBox “this” & “that”
End If
End Sub
Wow, greater than, less than and ampersands! Here’s how you do it:
<code lang=”vb”>Code goes here</code>
Good morning, Dick –
Testing “not equals”
‘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
Just get a search and replace plugin (i.e. http://wordpress.org/extend/plugins/search-and-replace/) and replace “
” with the closing tag, and you should be set.
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.
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.
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
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
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.
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.
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.
Dick –
Looks great! Don’t have to worry about blank lines, too! An added benny.
…mrt
Dennis: CodeColorer can do line numbers as well.
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?
Doug – you can’t use plugins with wordpress.com-hosted blogs.
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.
Doug,
I will let you know as soon as I have fully tested it.
Kind regards,
Dennis
[…] 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 […]