DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2007
    Posts
    3

    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.
    Code:
                              object rObj ;
    
                                object objcls1 = "cls1 ";
                                object objcls2 = "cls2";
                                
                                VBA.Collection objCollection = (VBA.Collection)myToolFrame.ActiveObjects;
    
                                try
                                {
                                    rObj = objCollection.Item(ref objcls1);
                                    m_windowDistributor_ActivateCurrent(ref rObj);
                                }
                                catch (COMException exception)
                                {
                                   //Giving exception here if the item is not cls1 type
                                }
    
                                try
                                {
                                    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
    Location
    Sterling Heights, Michigan
    Posts
    8,652
    Try using an empty Catch....
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

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

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
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links