Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 724647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:14:47+00:00 2026-05-14T06:14:47+00:00

I am currently maintaining some code, which is likely to be refactored soon. Before

  • 0

I am currently maintaining some code, which is likely to be refactored soon. Before that happens, I want to make the standard error handling code, which is injected by an Add-In, more efficient and take up less space. One thing that annoys me is that every module has a constant called m_ksModuleName that is used to construct a big string, which is then rethrown from the error handler so we can trace the error stack. This is all template code, i.e., repetitive, but I could easily strip it down to a procedure call. Now, I have fixed the code so that you can pass the Me reference to the procedure – but you can’t do that for the BAS modules. Nor can you access the project name (the part which would be passed as part of a ProgramID, for instance) – although you get given it when you raise an error yourself.

All these strings are contained in the EXE, DLL or OCX – believe me, I’ve used a debugger to find them. But how can I access these in code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:14:48+00:00Added an answer on May 14, 2026 at 6:14 am

    AFAIK there’s no way to get the name of a BAS module in code. The usual solution is to use a module-level constant as in Mike’s answer.

    AFAIK the only way to get the ProgID (programmatic ID, Project Name in project properties dialog) is to raise an error in a BAS module, trap it, and read the Err.Source.

    It’s all quite a hassle, and that’s why we don’t usually bother including the module name or the ProgID in our standard error handlers. We “roll our own” call stack, with the names of the routines. That’s always enough information to find out which modules are involved. Routines in BAS modules usually have unique names, right?

    Something like this, and you can add this automatically with the free MZTools VB6 add-in.

    Sub / Function whatever 
    On Error Goto Handler
    do some stuff
    Exit Sub / Function
    
    Handler:
    Err.Raise Err.Number, "(function_name)->" & Err.source, Err.Description 
    End Sub
    

    Every top-level routine in a DLL or OCX has a similar error handler but also includes App.ExeName so we can tell when errors cross component boundaries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am maintaining some Java code that I am currently converting to C#. The
I'm currently maintaining some flex code and noticed very many functions which are declared
I have an ASP.NET site that I am maintaining. Currently it has code that
I am currently maintaining some Wordpress MU installations ( v2.9.x ) I want to
I'm currently maintaining some old code for a company. As it would happen, the
I am writing/maintaining some heavily templated code in c++. I am currently compiling it
Here's a snippet of code that I saw in some code I'm maintaining. Object
I'm currently maintaining some web server software and I need to perform a lot
I'm currently maintaining a project I've inherited from some one else and the SVN
I'm currently maintaining an "old" system written in C# .NET, removing some obsolete features

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.