Wednesday, July 22, 2009

Getting Started Building HTML Help Files (.CHM) from Visual Studio's XML Documentation

If you want to build HTML Help files (.CHM) from the XML Documentation embedded in your .NET code, here is a good post on how to get started:

Here is some more information after you get going:

Here is even more good info on the XML Documentation Syntax from Alan Dean:

Making your .CHM FIles (HTML Help) use a larger Font

This post is a little off topic, but this tip is worth a little more press.

If you can't read a .CHM file (HTML Help file) because the font is just too small, you can make it readable again (Thanks Garth Jones).

Options/Internet Options/Accessibility -> Ignore Fonts Sizes on specified Web pages

Monday, July 20, 2009

Good Example of using IDisposable with File Streams

Here is a simple, yet good example of how to implement IDisposable when dealing with File Streams:

Here is a similar example with some discussion, but the first link is probably better:

Creating Custom Dictionary for Code Analysis in Visual Studio

Here is a good description of how to add your own custom words to the spelling dictionary used by Visual Studio's Code Analysis Naming rules (also known as FXCop):

Friday, July 17, 2009

Getting Started with Virtual Earth/Bing Maps

Here is a great video on how to get going with Virtual Earth (now Bing Maps).

This video gets you through all of the problems that show up that the documentation fails to cover.

Monday, July 6, 2009

Setting the Exit Code when exiting a VB.NET or C# Console App

To set the Exit Code (ErrorLevel) when a VB.NET or C# Console Application exits, use the following (or similar):

Dim retCode as Integer = 0
System.Environment.Exit( retCode)

The call to Exit will end the application.

Thursday, July 2, 2009

Implementing a SQL-like 'LIKE' Comparison in VB.NET

I searched the net for some time to find an easy way to implement the logic in the SQL LIKE in a VB.NET function. There were many over simplified examples. Then I found this elegant solution using regular expressions (regex). The original is found here in C#:

I have provided a VB.Net version below:

Public Function IsSqlLikeMatch(ByVal input As String, ByVal pattern As String) As Boolean

' Turn "off" all regular expression related syntax in
' the pattern string.

pattern = Regex.Escape(pattern)

' Replace the SQL LIKE wildcard metacharacters with the
' equivalent regular expression metacharacters.

pattern = pattern.Replace("%", ".*?").Replace("_", ".")

' The previous call to Regex.Escape actually turned off
' too many metacharacters, i.e. those which are recognized by
' both the regular expression engine and the SQL LIKE
' statement ([...] and [^...]). Those metacharacters have
' to be manually unescaped here.

pattern = pattern.Replace("\[", "[").Replace("\]", "]").Replace("\^", "^")

Return Regex.IsMatch(input, pattern)

End Function