Results 1 to 10 of 10

Thread: how to get function name in which the error occurred ,vb6

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,954

    how to get function name in which the error occurred ,vb6

    How to get the name of the function in which the error occurred?

    function test()
    on error goto err1:
    ****
    exit function
    err1:
    'how to get function name:test
    ErrInfo = Err.Source & ",?" & Err.Number & ",?" & Err.Description
    end function

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,546

    Re: how to get function name in which the error occurred ,vb6

    Code:
    ErrInfo = Err.Source & ",?" & Err.Number & ",?" & Err.Description & ",Function-Name: Test"
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  3. #3
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,073

    Re: how to get function name in which the error occurred ,vb6

    I use the AddIn MZTools, this let’s insert an error handler with a single click from a template. It fills the template with the correct procedure name. There is no method available in VB6 to get the current procedure name

  4. #4
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,030

    Re: how to get function name in which the error occurred ,vb6

    Not natively... but I'm sure The trick begs to differ on whether it's possible at all

    It's probably possible with undocumented runtime stuff from p-code, and I know it could be done in native code if you generate a pdb file (VB has an option for this).

    Over in the future of course, tB has CurrentProcedureName (and CurrentComponentName, CurrentSourceFile, CurrentComponentCLSID, and CurrentProjectName) (Sorry, when the issue of 'I wish the language had 'x' feature comes up, and *it does* in the de facto new version...)

  5. #5
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,073

    Re: how to get function name in which the error occurred ,vb6

    Quote Originally Posted by fafalone
    Not natively... but I'm sure The trick begs to differ on whether it's possible at all
    I believe from previous threads that the procedure name is not available compiled executable

  6. #6
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,642

    Talking Re: how to get function name in which the error occurred ,vb6

    The only reliable method I've seen so far is declaring a string constant in each function which is highly annoying but gets the job done.

  7. #7

  8. #8
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,030

    Re: how to get function name in which the error occurred ,vb6

    Quote Originally Posted by The trick View Post
    Does that require a pdb file?

  9. #9

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,954

    Re: how to get function name in which the error occurred ,vb6

    Maybe having twinbasic add a compile option would do that.
    errinfo=[funname] & err.number &

    Obtain the name of the public function and private procedure, the offset of the virtual table and the number of parameters in the VB6 form
    This can be done in the VB6 IDE, and the type library information will all disappear after compilation.
    I used to use the top object to hold the function name and offset.If you insert another function, this offset changes.I just need to modify the dictionary object, and it will run normally after compilation.
    Last edited by xiaoyao; May 24th, 2024 at 06:48 PM.

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