Programatically retrieving sub/function name?

  • Thread starter Thread starter Rick Derthick
  • Start date Start date
R

Rick Derthick

Hello,

I'm adding a logging capability to error handler routines for
troubleshooting (using vb.net) and had just recently come across a way to
programatically determine the name of the subroutine or function.

For example...

Private Sub SomeRoutine()
Dim strRoutineName

strRoutineName = ??????? 'where strRoutineName would be equal to
"SomeRoutine"
End Sub

Can someone provide an example of how to accomplish this? I'm trying to
keep the error handler code uniform thoughout the project and therefore
would rather not hard code the name of the routine into each error handler.

Thanks
Rick
 
Rick,

System.Reflection.MethodBase.GetCurrentMethod().Name



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top