Program Name and Line Number

  • Thread starter Thread starter Alex Campos
  • Start date Start date
A

Alex Campos

Using vb.net - how can I find the current program name and line number as I
am running through the code without there being an error.
 
Using vb.net - how can I find the current program name and line number as
I
am running through the code without there being an error.

Take a look at the "System.Diagnostics.StackFrame" class. It should give
you what you're looking for so long as you're running in "debug" mode.
 
Here you go... This is C#, but it translates very easy:

StackTrace stackTrace = new StackTrace(Thread.CurrentThread, true);

StackFrame frame = stackTrace.GetFrame(0);

Console.WriteLine("File Name: {0}, Line Number: {1}",

frame.GetFileName(), frame.GetFileLineNumber());



Regards,



Bennie Haelen
 
Back
Top