June 29, 2002

Exclude code portions with the Conditional attribute

VB developers have always used the #IF compiler directive to include or esclude portions of code from the application. The problem with this directive is that you can easily exclude a procedure with a single directive, but it isn’t easy to discard all the calls to that procedure (which would

Understanding passing arrays by reference

.NET arrays are object types, thus an array variable is actually a pointer to the object where data is actually stored. For this reason, when you pass an array to a procedure the pointer is passed and the called procedure is always able to modify the elements of the array,

Map an enumerated value to a set of OptionButton controls

In VB6 and previous version, displaying an enumerated value in a group of option buttons is quite simple, provided that the option buttons be grouped in a control array. VB.NET doesn’t support control arrays, so you can’t reuse the same simple coding techniques. However, you can prepare a couple of

Evaluate an expression at runtime

The .NET framework doesn’t offer any direct way to evaluate an expression that has been entered by the end user when the application is running. However, it is quite simple to create a simple expression evaluator based on calculated columns in DataTable. The following routine does the trick: Function EvalExpression(ByVal

Change the application priority

The application’s priority – and more in general the thread’s priority – indicates how the application is “important” for the CPU. The more the priority is hight the more the CPU will dedicate his time to execute it.In .NET the priority of a thread is indicated to the Thread.Priority property.