|
-
Sep 18th, 2000, 07:44 PM
#1
Thread Starter
New Member
How do I get the name of a Procedure automatically so
I can report it in my error handling.
eg
Sub DoSomethingCool()
OnErr: <error handler > "Error, " & err, & "occurred in DoSomethingCool"
End Sub
i.e. is there a way to handle this better so that if the procedure name changes the erorr handler picks up the new change, without having to modify the error handler message?
-
Sep 18th, 2000, 07:47 PM
#2
Hyperactive Member
How do you get it?
You type it in 
Yeah I know... it sux but unfortunately Visual Basic doesn't have any method of getting the name of the current procedure.
The reason for this is that when you compile a VB application it gets rid of all the textual names you give to things so it can reduce it to the smallest possible size. This means your wonderful "MyBestProc" is reduced to simply a memory address that is references.
You therefor cannot return the name of something that doesn't strictly exist as far as the compiled exe is concerned.
As the only reason you WANT this name is for debugging it says that the name only has meaning to the coder. The only way to do it is pass the name of the procedure and re-type it every single time you add this bit of code to the end of a procedure...
I know its long winded but unfortunately its the only way.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|