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)

MsgBox(msg)

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
http://www.codeproject.com/cs/miscctrl/htmlrichtextbox.asp

Use IRichEditOle from C#
http://www.codeproject.com/cs/miscctrl/richtextboxplus.asp

Insert Plain Text and Images into RichTextBox at Runtime
http://www.codeproject.com/cs/miscctrl/csexrichtextbox.asp

AutoFormatter
http://blogs.vbcity.com/hotdog/archive/2004/09/11/280.aspx?Pending=true

The HtmlEditor - a C# control that wraps MSHTML
http://www.itwriting.com/htmleditor/index.php

MSWord Automation Converting RTF to TXT format
http://www.codeproject.com/csharp/rtftotxtconvertor.asp#xx1196725xx

Copy as Html (VS Add-in)
http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/

VB.net function to convert rtf to html
http://www.developer.com/net/vb/article.php/10926_1576561_3