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:

http://saftsack.fs.uni-bayreuth.de/~dun3/archives/integrate-xml-code-comments-into-visual-studio-20052008-using-sandcastle-and-html-help-20/150.html


Here is some more information after you get going:

http://www.codeproject.com/KB/XML/csharpcodedocumentation.aspx

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

http://thoughtpad.net/alan-dean/cs-xml-documentation.html

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).

http://smsug.ca/blogs/garth_jones/archive/2008/10/20/tip-of-the-day.aspx


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:


http://www.blackwasp.co.uk/IDisposable.aspx


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

http://stackoverflow.com/questions/1136210/am-i-implementing-idisposable-correctly

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):

http://duncanjasmith.blogspot.com/2008/07/creating-custom-dictionary-for-code.html

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.

http://www.liveside.net/developer/archive/2008/09/29/video-getting-started-with-the-virtual-earth-web-service.aspx

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#:

http://bytes.com/groups/net-c/253519-using-regex-create-sqls-like-like-function


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