SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 7 of 7

Thread: TypeOf

  1. #1
    SQA Council
    Join Date
    Mar 2001
    Posts
    14,438
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    TypeOf

    User Steve Gray (sgray@BridgeMedical.com.nospam) posted:

    Anybody use the TypeOf function successfully? WHat the heck is the
    className to which Online help refers? IOW, I have an
    InternetExplorer.Application object and an Excel.Application object - I want
    to create a function to which I can pass either object, and have it
    determine which one was passed. Don't take this example literally, it could
    be two completely different objects, like InternetExplorer.Application and
    it's child "Document" object, or whatever... I just need to see this TypeOf
    function working, and I can figure out the rest...

    BTW - These do not work:

    Dim objVar = CreateObject("InternetExplorer.Application")

    If TypeOf objVar is "InternetExplorer.Application" Then

    If TypeOf objVar is InternetExplorer.Application Then

    If TypeOf objVar is "Application" Then

    If TypeOf objVar is Application Then

    If TypeOf objVar is "InternetExplorer" Then

    If TypeOf objVar is InternetExplorer Then

    ---

  2. #2
    SQA Council
    Join Date
    Mar 2001
    Posts
    14,438
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: TypeOf

    User (lgoodwin@russell.com.nospam) posted:

    I had the same results, so check against VisualBasic 5.0.
    This syntax works in VB, but in SQABasic (Robot 2002), I get Errors
    "'Excel' is not a class", "IF syntax error" and "Missing END IF":

    If Typeof objExcel Is Excel.Application Then

    Else

    End If

    This got me thinking the usual classes might not be supported when using
    OLE automation. I found the "Class List" help file, which states "The
    following class can be used in a Dim statement, a Typeof expression, or
    with the New operator:", and the only class listed is "Object".

    However, when I tried specifying object class as Object, I got "This class
    does not support TYPEOF"! I don't think this expression works with OLE
    automation.
    Can anyone out there prove me wrong?

    Luke


    ---

  3. #3
    SQA Council
    Join Date
    Mar 2001
    Posts
    14,438
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: TypeOf

    User (MMcNaughton@STSSystems.com.nospam) posted:


    Only used TypeOf for Object, integer etc... I wonder if the class name is
    looking for something strange like FindWindow is when looking for Excel:

    hwnd = FindWindow("XLMAIN", "Microsoft Excel")

    The Class Name is actually XLMAIN

    You might try IEFrame for Internet Explorer, it the class that i get listed
    with my API Spy application.


    If TypeOf objVar Is "IEFrame" Then


    Good Luck,
    Max


  4. #4
    SQA Council
    Join Date
    Mar 2001
    Posts
    14,438
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: TypeOf

    User (MMcNaughton@STSSystems.com.nospam) posted:


    Sorry VarType is what i was thinking of, this TypeOf seems to be a pipe
    dream. However you may look into doing something like, not as elegant
    though, look into using .Name on your objects:

    oObject (could be for instance IE or Excel as in your example or XML
    whatever)

    oObject.Name will give you either "Microsoft Excel " or "Microsoft Internet
    Explorer"

    So you could branch based on possibility parsing looking for Excel or
    Internet Explorer which would be unique or Microsoft will sue...

    Const typeExcel as Integer = 1
    Const typeIE as Integer = 2
    Const typeUnknown as Integer = 3

    Function GetDataType (oObject as Object) as Integer
    If InStr(oObject.Name, "Excel") <> 0 Then
    GetDataType = typeExcel
    Exit Function
    End If

    If InStr(oObject.Name, "Internet Explorer") <> 0 Then
    GetDataType = typeIE
    Exit Function
    End If
    GetDataType = typeUnknown
    Exit Function
    End Function

    HTH,
    Max

  5. #5
    SQA Council
    Join Date
    Mar 2001
    Posts
    14,438
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: TypeOf

    User Gustavo Rojas (grojas@microsoft.com.nospam) posted:

    The vagueness of the "Help" information is tremendous and not very
    informative, IMHO. The easiest way I would think is just pass a
    parameter with the class name you created. The same If statement or Case
    statement you would use with the TypeOf statement you would use to
    validate the parameter. You would know what kind of object you're
    passing when you call the function to begin with, so save yourself a lot
    of time for now and try something like this. When someone gets more
    information about this they will surely help you, me included.

    Gustavo Rojas
    ____________________________________
    Microsoft Great Plains Business Solutions
    Software Test Engineer
    Solomon Platform Services Group



  6. #6
    SQA Council
    Join Date
    Mar 2001
    Posts
    14,438
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: TypeOf

    User Steve Gray (sgray@BridgeMedical.com.nospam) posted:

    It's a bug. Rational is looking into it - the TypeOf function is broken.
    Hope this doesn't turn into "GetField"... TypeOf could be a very useful
    function, as described in "Help..."

    ---

  7. #7
    SQA Council
    Join Date
    Mar 2001
    Posts
    14,438
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: TypeOf

    User (MMcNaughton@STSSystems.com.nospam) posted:

    Bet they were 'surprised'. In this case it's been 'broken' since at least
    6.0 since it appears in that version as well with the same Help... )

    Max


 

 

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 Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 13.64%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 02:31 AM.

Copyright BetaSoft Inc.