Results 1 to 4 of 4

Thread: [RESOLVED] Testing for an Object that is not added as a component or reference

  1. #1

    Thread Starter
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Resolved [RESOLVED] Testing for an Object that is not added as a component or reference

    Is there any way to test for any object even if it is not added as a component?

    Here's the problem. I want to have code that can handle a few known objects such a TreeView, SSTab and a few others. Now I want the code to be independent of these object it is to test for. Meaning there are no references to it. Is there a dynamic way to see if an object passed to a routine is the type of object you are looking for in this manner.


    IE.

    If TypeOf ctl is TreeView then ...

    What I want is

    If TypeOf ctl is (A dynamic object treeview representation) then ...

  2. #2
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Testing for an Object that is not added as a component or reference

    Can you use TypeName instead of TypeOf ?

    vb Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     Dim obj As Object
    5.     Set obj = CreateObject("InternetExplorer.Application")
    6.  
    7.     If TypeName(obj) = "IWebBrowser2" Then
    8.         obj.Visible = True
    9.         obj.Navigate "http://www.google.com"
    10.     End If
    11.  
    12. End Sub
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3

    Thread Starter
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Testing for an Object that is not added as a component or reference

    There's a thought... I will look into that.

  4. #4

    Thread Starter
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Testing for an Object that is not added as a component or reference

    Works just fine... Thanks

Posting Permissions

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



Click Here to Expand Forum to Full Width