473,808 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
"SomeRoutin e"
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 1756
Try This,
MethodBase.GetC urrentMethod(). Name form the System.Reflecti on 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 "SomeRoutin e"
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
"SomeRoutin e"
End Sub


\\\
MsgBox(System.R eflection.Metho dBase.GetCurren tMethod().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
5414
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 is required to be installed and if not, which version of the program database needs to be installed with the current version of Access. (hope that makes sense). If anyonoe could point me in the right direction, I'd really appreciate it.
4
17260
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 do myDomElement.click and the mouse doesn't matter, but in the case of an input image element, what happens is the submitted url has something like "?x=12&y=7" appended to it (the numbers vary per mouse position on the clicked element). If you hit...
3
11823
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 if any tables have been addedd to A and if so, programatically creating a linked table to the new tables? Failing this, can I programatically delete all linked tables, then link re-link to every table which appears in tableA?
2
2304
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
3481
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 know in IIS 6.0, I could retrieve it through metabas.xml but I need this solution to work on Windows 2000, IIS 5.0 as well. Many Thanks in advance for your help
2
2010
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. Basically i want to know how i retrieve information from the form so i can disaply it in the table. i have put the code i am using below, the feature i cannot get to work is the change content function. I want the email address entered by the...
7
1572
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: 100 b: 200 I get the feeling this is trivial, but I have been unable to find an answer on my own.
0
3399
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 within options. I have everything being dynamically named from the previously dynamically named element. (I hope this makes sense.) I am not able to retrieve any of the dynamically created values. I can view them on the source page but can't pull them...
34
2596
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 is below: <CUSTOMER>
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5547
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3859
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.