Wednesday, January 25, 2006

A VS2005 macro to measure the length of string laterals in the code editor

The following macro, is a Visual Studio macro to measure the length of string laterals in the code editor.

Highlight the string and run the macro, a message box will show the length

Sub MeasureStringLength()
Dim ts AsTextSelection = DTE.ActiveDocument.Selection
Dim msg As String
msg = String.Format("{0}{1}{2} char(s)", ts.Text, ,vbCrLf ts.Text.Length)


End Sub

How to use
1. Select a string in the Code Editor

2.Run the Macro

3.See the Msessage Box with the length

It is also easy to assign the macro to a custome toolbar button in VS2005, or give it a Keyboard short cut

Tuesday, January 17, 2006

RTF to HTML using C#

I have searched for a code snippet or an (.net) open source utility to convert an RTF string into an HTML string

Many stuff are there, but all has some limitations to what I need exactly.

Here is some of the search result

ExRichtextBox with lite HTML

Use IRichEditOle from C#

Insert Plain Text and Images into RichTextBox at Runtime


The HtmlEditor - a C# control that wraps MSHTML

MSWord Automation Converting RTF to TXT format

Copy as Html (VS Add-in) function to convert rtf to html