Link to home
Start Free TrialLog in
Avatar of NikWhitfield
NikWhitfield

asked on

Logging the current sub's name....

Hi,

    I'm sure this comes up all the time. I would like to log errors / information and report the name of the sub / function from which they come. Is there any way to do this implicitely? Basically, I need a call which returns the current sub's name. Can it be done?

Cheers, Nik.
ASKER CERTIFIED SOLUTION
Avatar of wsh2
wsh2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ture
ture

Nik,

There is no built-in functionality for this.

The way to do this is to declare a global variable and set its value at the beginning of each procedure.

Ture Magnusson
Karlstad, Sweden
Hi Nik
At the start of application open the log file using Open statement .

In each critical procedure<u want log>, use On Error goto ErrHandler

In err handler Use Print # method to log the error along with time etc:


'say number is 1 for LogFile
Exit Function
ErrHandler:
Print #1, Now & ": Function GetValue:" _
& Err.Descripotion

Hope it helps.