Professional Excel Development [Electronic resources] : The Definitive Guide to Developing Applications Using Microsoft® Excel and VBA® نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Professional Excel Development [Electronic resources] : The Definitive Guide to Developing Applications Using Microsoft® Excel and VBA® - نسخه متنی

Stephen Bullen, Rob Bovey, John Green

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید











Error Handling in Classes and Userforms


Classes and userforms present some unique error handling challenges that we cover in this section. As explained previously, event procedures in classes and userforms should almost always be considered entry point procedures. The Initialize, Activate and Terminate events are exceptions to this rule. The user does not directly trigger these events. Instead, they are fired as a side effect of a class being created or destroyed or a userform being created, shown or destroyed. Error handling for these events is a little tricky, so we discuss them in detail.

Initialize and Activate Events


Errors that occur in Initialize or Activate events are typically catastrophic errors that render the class or userform in which they occur unusable. Therefore, they normally cannot be handled in any way that would mitigate them. If you are going to place code in either of these event procedures, the best option is not to give them an error handler at all. This will delegate the handling of any errors that occur inside these event procedures to the error handler of the procedure that attempted to create the object.Putting It All Together section below, we show an example of a custom Initialize method in a userform.

Terminate Events


Errors that occur in Terminate events are unusual in that, assuming proper programming techniques have been used, neither are they catastrophic nor can they be mitigated. When the Terminate event is fired, the class or userform has performed its function and is being destroyed. If you need to place code in the Terminate event of a class or userform, it is best to simply ignore any errors that occur by using the On Error Resume Next statement at the beginning of the procedure.


/ 225