posts - 4238, comments - 3946, trackbacks - 370

My Links

News



Subscribe Subscribe

image image image





This is my personal weblog. These postings are provided 'AS IS' with no warranties, and confer no rights. The views expressed on this weblog are mine alone and do not necessarily reflect the views of my employer.

Licenza Creative Commons

Tag Cloud

Archives

Post Categories

VB... volete sapere a che riga c'è stato un errore?

Usate una feature dimenticata nel tempo... ma ancora presente!

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 occured in line: " & Erl())
70: End Try
80: Console.ReadLine()

The output is:

   Error occured 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.

Fonte: VB.ReallyOld features still in VB.2005

Print | posted on mercoledì 21 dicembre 2005 23:18 |

Comments have been closed on this topic.

Powered by:
Powered By Subtext Powered By ASP.NET