DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2007

    COMException in VBA Collection

    Hi All,

    I am converting a Visual Basic 6.0 application to C#.

    I need to use VBA Collection object(that is cliect requirements).But sometimes while getting the items from collection object as "

    objCollection.Item(ref objclsBOMPresentations)" ,it is giving COMException.So I need to give one if else block to get the type of the item index.

    As you can see in the code,that is hardcoded.So I am giving try catch exception to make the control go on.Please suggest me how can I implement IF-Else here.
                              object rObj ;
                                object objcls1 = "cls1 ";
                                object objcls2 = "cls2";
                                VBA.Collection objCollection = (VBA.Collection)myToolFrame.ActiveObjects;
                                    rObj = objCollection.Item(ref objcls1);
                                    m_windowDistributor_ActivateCurrent(ref rObj);
                                catch (COMException exception)
                                   //Giving exception here if the item is not cls1 type
                                    rObj = objCollection.Item(ref objcls2);
                                    m_windowDistributor_ActivateCurrent(ref rObj);
                                catch(COMException exception)
                                 //Giving exception here if the item is not cls2 type                          
    Last edited by Hack; 12-31-2008 at 10:15 AM. Reason: Added Code Tags

  2. #2
    Join Date
    Apr 2007
    Sterling Heights, Michigan
    Try using an empty Catch....

Similar Threads

  1. Searching a Collection
    By carrotjava in forum Java
    Replies: 1
    Last Post: 02-24-2005, 06:42 AM
  2. .NET Collection Classes
    By Russ Scherbarth in forum .NET
    Replies: 3
    Last Post: 03-31-2003, 03:41 PM
  3. collection philosophy
    By will in forum .NET
    Replies: 3
    Last Post: 10-26-2002, 07:40 PM
  4. Collection classes revisited
    By Marco Antonio Pérez López in forum .NET
    Replies: 0
    Last Post: 06-09-2001, 10:22 PM
  5. Collection Classes revisited
    By Marco Antonio Pérez López in forum .NET
    Replies: 0
    Last Post: 06-09-2001, 10:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.