Tuesday, May 19, 2009

Using the Visual Studio Editor Regular Expression Search/Replace

I always forget this so I'm saving it here

If you want to save a string and then use it in the replace box put a {} around it.  Then you can refer to it using \1 or \2 (depending on how many curly brackets you put.

Ok, if you want more info you can check out the three part tutorial.


Or this site which compares it to regular regex.

How do I configure the Visual Studio debugger to break when an exception is thrown?


In Visual Studio go to the Debug | Exceptions | Common Language Runtime Exceptions | System and select System.NullReferenceException.

In the When the exception is thrown group box, select Break into the debugger.

Run your scenario. When the exception is thrown, the debugger will stop and notify you with a dialog that says something like:

An exception of type "System.NullReferenceException" has been thrown.

[Break] [Continue]

Select [Break]. This will put you on the line of code that's causing the exception.

vb6.GetPath replacements





Vb6.FixedLengthString(2048) to Space(2048)

When we converted code from VB6 to .NET the following call was specified for a string that was a specific length

Dim astr as New VB6.FixedLengthString(2048)

In .NEt the replacement is
Dim aStr as String = New SpacE(2048)

This works just like the VB6. function call.

VB6.Format(tempstr, "mmm dd, yyyy") to CType(tempstr, Date).ToString("MMM dd, yyyy") in VB.NET 2005

VB6.Format(tempstr, "mmm dd,yyyy")
CType(tempstr, Date).ToString("MMM dd,yyyy")

The MMM gives you Jan as opposed to 01
For more information and all the formats go to :

Replace Format(Now, "yyyymmdd") with Date.Now.ToString("yyyymmdd") in VB.NET 2005

Previously in VB6 we were doing
Format(Now, "yyyymmdd")
in .NET do the following Date.Now.ToString("yyyymmdd")

Monday, May 18, 2009

Replacement for VB6.Format(Number, "00") in VB 2005

When I converted the project from VB6 to VB.NET, either the Converter or someone on our team used the Microsoft.VisualBasic.Compatability library for the following code:
 VB6.Format(anumber, "00")
the replacement in .NET 2005 is:
CStr(anumber).PadLeft(2, "0")