June 22, 2002

Create a command-line filter utility

The Console class exposes two properties that make it very simple to create command-line utilities that work as filters, exactly like the FIND and MORE utilities that are provided with the operating system. The Console.In property returns a TextReader object that reads from the standard input channel, and Console.Out returns

Write applications that take arguments

C# has a nice feature that VB.NET lacks: the ability to define a Main procedure that takes an array of strings, each one containig one of the arguments passed on the command line. It’s easy to mimick this feature in VB, though.In fact, while the Command function is still supported

Duplicate the SET operating system command

The Environment.GetEnvironmentVariables property returns the list of all the environment variables, as an IDictionary object. If you want to display them sorted by their name, as the SET command does at the prompt, you need the following tricky code: ‘ Get all the variables, as an IDictionary objectDim vars As

Create console apps that return an exit code

Writing an application that returns an ERRORLEVEL to Dos is quite difficult in VB6, because you are forced to use a Windows API that ends the application immediately, thus preventing orderly release of resources. Conversely, this task is quite simple in VB.NET, thanks to the Exit static method of the

Take advantage of the new math functions

The System.Math class exposes several static methods that let you perform many common operations. These functions replace the VB6 functions with same name, but there are a few new functions that have no direct VB6 counterpart:Ceiling(x) returns the integer equal or higher than the argumentFloor(x) returns the integer equal or