November 24, 2001

Lessons Learned in Enterprise Design and VB6

t’s now been more thantwo years since I wrote the article “18 CommonProgramming Traps in MTS.” The article wasgreat fun to write, and I received, and in fact am still receiving, a lot ofpositive feedback from readers. I wrote the article after having worked withMTS, VB6 and SQL Server for

Providing a default value for optional arguments

Unlike VB6, VB.NET requires that you specify the default value of any Optional argument. In general you should use a value that is invalid under normal circumstances, so that the called procedure can discern whether the argument has been actually passed or not. For example, you should use -1 as

Leverage the improved Shell function

The version of the Shell function included in VB.NET expands on the original version and supports an additional argument that enables you to specify whether to wait until the shelled program terminates, with an optional timeout. This solves an old problem known to many Visual Basic developers without your having

Exception debugging in Visual Studio .NET

The Visual Studio debugger offers complete control on what happens when an application throws an exception, or calls a .NET method that throws an exception. You set all the relevant options from inside the Exceptions dialog box, which you bring up with the Debug | Exceptions menu command. This dialog

Use a ParamArray as a true array

Unlike VB6, in VB.NET the ParamArray keyword defines a true array object, which you can process using any of the methods of the Array class. For example, here’ s a function that evaluates the lowest value among those passed to the procedure, using the static Array.Sort method and then taking

Use the Err.GetException method to create custom exceptions

The Visual Basic .NET Err.Raise method and the Throw command are (partially) compatible. For example, you can use a Try…End Try block to catch an error raised with the Err.Raise method, and you can use an On Error Resume Next and the Err object to neutralize and inspect an exception