Results 1 to 5 of 5

Thread: Raising Errors to a common module

  1. #1

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610

    Raising Errors to a common module

    I have been using RaiseEvents to get my errors in my lower classes up to my superclass. (Thanks Honeybee) I would now like to raise an event from the superclass to let the calling application know there has been an error. It seems as though that it is not possible to check for events in a module, you have to use a class or a form (which I am not using in my code).

    Is there a way around this?
    This space for rent...

  2. #2
    SeanR
    Guest
    This may not be it but check your error trapping settings under
    Tools -> Options -> General Tab in VB

    Regards

    Sean

  3. #3
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    There is no way of raising events from a standard module, but if you are using classes, you should not need any standard modules. Anyway, one method is to raise an error as soon as you trap the error event of the subclass. So if some code is using functions from your standard module which use class methods, an error will be encountered by the class method, raised to the module by way of an event, and in this event you can again use Err.Raise statement to return the error back to the calling program.

    I really think you should not need standard modules in classes, but if you want to know that's how it could be done.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  4. #4

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610
    I confused you a little bit. The standard module would not be in my class project but in my EXE project.

    I did not see a way to get an Event that was raised in the class project to be recognize by the EXE project except for using Err.Raise. Am I missing something?
    This space for rent...

  5. #5
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    When declaring reference variables for your classes, use the WithEvents keyword, such as:

    Dim WithEvents MyObj As clsMyClass

    Now, you can select MyObj from the dropdown list of controls in the IDE and use its events.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

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