473,386 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Programatically retrieving name of a sub/Function?

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
Nov 20 '05 #1
2 1737
Try This,
MethodBase.GetCurrentMethod().Name form the System.Reflection namespace
Regards - OHM

Rick Derthick wrote:
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

Nov 20 '05 #2
* "Rick Derthick" <Ri**@aol.com> scripsit:
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


\\\
MsgBox(System.Reflection.MethodBase.GetCurrentMeth od().Name)
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: RWC | last post by:
Hi Folks, I'm looking for a way to determine if the client machine has access installed and if so, what version. The reason I need this is to determine (programatically) if the Access Runtime...
4
by: Csaba2000 | last post by:
I want to be able to programatically click on the center of an <INPUT type=image ...> element (I only care about IE 5.5+). This should work regardless of whether IE has focus. Normally you would...
3
by: Tym | last post by:
OK - daft question of the day time... If I have database A which contains all the live data, and Database B which contains linked tables to those is A (i.e. a front end) is there a way of seeing...
2
by: Lumpierbritches | last post by:
Thank you in advance for any and all assistance. It is greatly appreciated. I would like to know if there's a way to programatically close any open form that doesn't have focus? Michael
3
by: Mike P | last post by:
Hi, During loading of the Global.asax, I need to get back the "application name" that is configured in IIS. I have scoured the Http classes but there does not seem to be any way to get to it. I...
2
by: 4Ankit | last post by:
hello all, i am having some difficulty retrieving information from my form. I want to add content in my table but the content i want to add to the table is what the user inputs in my form. ...
7
by: rodrigo | last post by:
How would I go about retrieving a variable's name (not its value)? I want to write a function that, given a list of variables, returns a string with each variable's name and its value, like: a:...
0
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options...
34
by: vpriya6 | last post by:
Hi guys, I am new to Ajax, xml and javascript. I want to know how can I retrieve data from xml and display in the html page? please help me out. suppose my xml file is customer.xml the code...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.