Results 1 to 4 of 4

Thread: Get Function Name

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Atlanta, GA
    Posts
    80

    Question

    Is there any way to get the current sub/function name from VB? For error logging purposes, I would like to call a WriteError function and pass the current sub/function that has caused the error?

    Thanks!
    Kevin
    Kevin

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Code:
    Private Sub JustASub()
    On Error Goto ErrorHandler
    
    'DO all the things you want in this sub
         Exit Sub 'when no errors occur
    
    'Copy the error handler in every function/sub
    ErrorHandler:
    Call WriteError(JustASub, Err.Number)
    End Sub
    
    Private Sub WriteError(ErrSub As String, ErrNr As Long)
    fn = FreeFile
    Open "err.log" For output as #fn
    Print #fn, "Error " & ErrNr & " occured in sub: " & ErrSub
    Close #fn
    End Sub
    That'll help ya!


    [Edited by Jop on 10-13-2000 at 12:01 PM]
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    No, there's not an 'official' way...

    but also try App.LogEvent and App.StartLogging, maybe those'll help ya!
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width