Getting sub or function name, programmatically
In vb6, Is there a programmatic way of getting the current sub or function name, similar to a form name
that is ...
the name of a form can be found by Me.Name.
Is there an equivalent for a sub or function ..
sub AddTotal(x as integer, y as integer)
' body of sub
msg="An error ocurred in" & sub.name
msgbox msg
end sub
Obviously, this syntax doesn't work, sub.name,
it's just an example.
re:Getting sub or function name, programmatically
If you have to assign the name of the sub or function manually to the global variable that you mentioned, in each sub or function, that defeats the whole purpose of the idea- right ??
The idea is to get the name of the sub/function without having to type in each sub/function name.
If your program has 600 functions, then you have to go through each function and type GlobalNameVar="MyFunc". That approach is pointless.
If VB has the feature where you can acquire the sub/function name using some built-in variable (ie.. me.name-> sub.name, or func.name) then you can add some error handling and logging code that is exaclty the same for each sub or function.
So- at this point, I still don't know if VB has a mechanism to get access to the current sub or function name.
Re: re:Getting sub or function name, programmatically
Quote:
Originally posted by cappy2112
If you have to assign the name of the sub or function manually to the global variable that you mentioned, in each sub or function, that defeats the whole purpose of the idea- right ??
The idea is to get the name of the sub/function without having to type in each sub/function name.
If your program has 600 functions, then you have to go through each function and type GlobalNameVar="MyFunc". That approach is pointless.
If VB has the feature where you can acquire the sub/function name using some built-in variable (ie.. me.name-> sub.name, or func.name) then you can add some error handling and logging code that is exaclty the same for each sub or function.
So- at this point, I still don't know if VB has a mechanism to get access to the current sub or function name.
Well, that's not an idea rather a problem in which you are trying to find a solution.. And that's the only solution I can think of:D.. I did not say that you insert this statement manually, you can create a service program that could do this for you for 600 functions.. Goodluck!
;)