+ Reply to Thread
Results 1 to 6 of 6

Sorting an array of a specific class module

  1. #1
    Registered User
    Join Date
    05-17-2013
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    3

    Sorting an array of a specific class module

    Hi there!

    I have a problem resulting in an "array or user-defined type expected" error.
    I have two class modules, EventClass and EventArrayClass. I am creating a discrete event simulation, which is not really important right now.
    I am trying to sort the EventClass array that is stored in an EventArrayClass object

    My EventClass has the following variables:
    Please Login or Register  to view this content.
    They are all available trough Get an Let methods:

    Please Login or Register  to view this content.
    The EventArrayClass consists of the following variables:
    Please Login or Register  to view this content.
    Adding an event to the EventArray goes according to this sub:

    Please Login or Register  to view this content.
    This will add the event to the array, while having the array sorted according to the EventTime of the different events.
    Now I have a method that will change the EventTime of a certain event, leaving the EventArray unsorted.
    Like the following:

    Please Login or Register  to view this content.
    Now I want to be able to call a Sub that will sort the Event Array.
    I try to do this using the QuickSort algorithm

    In the EventArrayClass I have the following two methods:

    Please Login or Register  to view this content.
    Calling the sub SortEventArray does no work. It results in an "array or user-defined type expected" error.
    I call the sub in the following test method:

    Please Login or Register  to view this content.
    To make it complete, the PrintArray in EventClassArray:

    Please Login or Register  to view this content.
    I hope someone can help me. I think the problem is in the reference to the EventArray in the method QSortEventArray, but I cant find out why.
    I hope the problem is clear. If not let me know.

    Help much appreciated!

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Sorting an array of a specific class module

    I cannot see a reason for that error with your code but there are issues with your quicksort. perhaps
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    05-17-2013
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Sorting an array of a specific class module

    Thanks! I did not know if the QuickSort worked since i cannot call the Sub.

    It however does not solve my current issue. Anyone any ideas?

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Sorting an array of a specific class module

    your posted code work for me after making those changes. can you post a workbook showing your issue?

  5. #5
    Registered User
    Join Date
    05-17-2013
    Location
    Amsterdam, The Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Sorting an array of a specific class module

    Hereby a file with the code.
    Attached Files Attached Files

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Sorting an array of a specific class module

    that workbook works for me after changing the sort routine as indicated. where does it actually break for you?

+ 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. [SOLVED] Class module / multidimensional array?
    By swoop99 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-09-2013, 09:31 AM
  2. [SOLVED] ComboBox class .AddItem filled in class module
    By Jacques Grobler in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-03-2012, 05:48 AM
  3. Replies: 1
    Last Post: 08-30-2011, 02:23 AM
  4. class module?
    By sybmathics in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 02-25-2006, 10:35 AM
  5. [SOLVED] class module
    By anonymousA in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-02-2005, 07:08 AM

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