VB.ReallyOld features still in VB.Net by ThinqLinq

VB.ReallyOld features still in VB.Net

While typing some code, I noticed that REM is still supported as a way to comment code. The only reason I can see why one would want to do this is to retain legacy code. There are some other really old features that haven't been documented since VB3, most notably the useful ERL() function. (It is back in the official documentation as well.) This means the following is valid VB.Net code:

10: REM This program doesn't do much
20: Try
30: REM Throw an error
40: Throw New DivideByZeroException
50: Catch ex As DivideByZeroException
60: Console.WriteLine("Error occurred in line: " & Erl())
70: End Try
80: Console.ReadLine()

The output is:

Error occurred in line: 40

The great thing about this, is that the line number is retained in a release build. I don't recommend using this globally in your applications as there is a performance hit (along with application bloat) but it is useful in selected circumstances. Naturally using the trace methods would be a better option.

Posted on - Comment
Categories: VB -
comments powered by Disqus