+ Reply to Thread
Results 1 to 6 of 6

Excel Crashes when using locals window to view custom-defined class

  1. #1
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Excel Crashes when using locals window to view custom-defined class

    I create a collection of several instances of this complicated class, but when I expand upon the item in the locals window when debugging, excel crashes (even when the collection contains one item). Please provide some clues to look for.

    It is a fairly complicated class that I use in a module that does not seem to have any issues when I define several objects, variables, and arrays. There are several private variables in the class including collections, other custom-defined classes, arrays, and several different variable datatypes. There are also several properties (some read-only some not), subroutines, and functions that all manipulate one or more private variables/objects/arrays at a time.

    Since my class is thousands of lines of code long, I have created a testclass that I'm using to crash excel on purpose to give me clues about what to look for. So if you don't have any ideas about what to look for, please provide some clues as to what would crash excel with a simple test class.
    Last edited by joe31623; 02-10-2016 at 10:58 AM.
    <---If my answer helped, please click *

  2. #2
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Excel Crashes when using locals window to view custom-defined class

    Notes:
    Windows 8 (not 8.1)
    There are no add-ins, Data links, etc.
    Virus software and Excel was updated w/i 2 weeks
    Only one instance of Excel is installed

    A List of private variables:
    Please Login or Register  to view this content.
    ...each collection typically has 1-6 CTradeSpread (custom-defined) objects, but I have Collections with over 200 CTradeSpread objects that works perfectly.
    Last edited by joe31623; 02-10-2016 at 11:21 AM.

  3. #3
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Excel Crashes when using locals window to view custom-defined class

    Using pre-processor commands, I narrowed down my arrow to the following subroutine and get property.

    First... for curious users, this is a brief overview of (how I use) pre-processor commands. If any knowledgeable programmers would like to share other uses of pre-processor commands, I welcome your comments.
    For forum users that do not know what preprocessor commands are (as I didn't a week or so ago), they allow some of your code to not run upon initialization by changing a value. It's useful for debugging when you write large blocks of code. For instance,
    Please Login or Register  to view this content.
    Thus... by only changing bool, when you run the code with bool = True a Msgbox would display the string: "Hello World" and with bool = False a Msgbox would display the integer: 42 with a single Msgbox(A) command.

    The next post will describe issues I'm having.

  4. #4
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Excel Crashes when using locals window to view custom-defined class

    After many hours... I have simplified and solved the problem. Now I want to know why.

    The following sequence of events with the following code will not crash excel when I view the instance: MyClass1 in the locals window by expanding it (clicking on the "+" that expands and displays all private variables defined in the instance of the class):

    1: I step through a subroutine in a module: MySub_InModule() line by line until I set a new instance: Set Inst_MC1 = New MyClass1 (on a separate line from the Dim statement)
    2: I expand Inst_MC1 to view all private variables (SUCCESSFULLY)
    3: I call subroutine: MySub_InClass using the previously-defined instance: Call Inst_MC1.MySub_InClass(InputToMCSub)
    4: I expand Inst_MC1 to view all private variables in the locals window (SUCCESSFULLY)

    '/Module: Module1
    Please Login or Register  to view this content.
    '/Class Module: MyClass1
    Please Login or Register  to view this content.
    The difference in the code above and code below is in bold.

    The following sequence of events with the following code will crash excel when I view the instance: MyClass1 in the locals window by expanding it (clicking on the "+" that expands and displays all private variables defined in the instance of the class):

    1: I step through a subroutine in a module: MySub_InModule() line by line until I set a new instance: Set Inst_MC1 = New MyClass1 (on a separate line from the Dim statement)
    2: I expand Inst_MC1 to view all private variables (SUCCESSFULLY)
    3: I call subroutine: MySub_InClass using the previously-defined instance: Call Inst_MC1.MySub_InClass(InputToMCSub)
    4: I expand Inst_MC1 to view all private variables in the locals window AND EXCEL CRASHES

    '/Module: Module1
    Please Login or Register  to view this content.
    '/Class Module: MyClass1
    Please Login or Register  to view this content.
    The read-only property for Int2 is simply:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Excel Crashes when using locals window to view custom-defined class

    More concisely:
    Why does pInt2 = pInt2 + Something crash excel but pInt2 = Int2 + Something not crash excel?

    (pInt2 is a private read-only variable with Public Property Get Int2() As Integer, defined in a custom-defined class and the operation: pInt2 = Int2 + something/pInt2 = pInt2 + something is performed/defined in a subroutine within which pInt2 is defined)

  6. #6
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Excel Crashes when using locals window to view custom-defined class

    soooo many hours over a little "p".

    Note: My question will be addressed in another thread: http://www.excelforum.com/excel-prog...not-crash.html

    Please leave any comments/answers about solving the problem statement in the thread referenced by the above linkback; however, someone wishes to comment about clever uses of pre-processor commands, please do so (unless this thread is updated with a linkback to a thread about pre-processor commands which I may post in the future).
    Last edited by joe31623; 02-11-2016 at 04:33 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel crashes when Macro is run, but only when the VBA window has been opened
    By EchoPassenger in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-04-2015, 08:55 AM
  2. control objects void of members in locals window
    By vientito in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-04-2013, 05:11 AM
  3. Why dont i see anything in the locals window or immediat window
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-14-2011, 10:01 AM
  4. 'Exporting' contents of Locals Window
    By mynci in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-27-2008, 05:15 AM
  5. Replies: 3
    Last Post: 04-03-2007, 04:44 AM
  6. [SOLVED] VBA Code runtime error only after opening Locals window
    By keeena in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-22-2006, 02:35 PM
  7. [SOLVED] What Custom View in MS Excel is used for?
    By Ismat in forum Excel General
    Replies: 2
    Last Post: 07-10-2005, 03:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1