Using IS NOT NOTHING

Discussion in 'AutoCAD' started by HJohn, Jan 16, 2004.

  1. HJohn

    HJohn Guest

    I am trying to check whether the object is nothing using If Obj is nothing then, but I get the error "Invalid use of object". This is necessary to check if a named dictionary exists or not.

    on error resume next

    Set Obj=thisdrawing.Dictionaries("DictionayName")

    if obj is not nothing then
    flag=true
    end if
     
    HJohn, Jan 16, 2004
    #1
  2. HJohn

    Joe Sutphin Guest

    if not obj is nothing then
    if this is all you have, it could actually be shorten to

    if not obj is nothing then flag=true

    Joe
    --

    then, but I get the error "Invalid use of object". This is necessary to
    check if a named dictionary exists or not.
     
    Joe Sutphin, Jan 16, 2004
    #2
  3. HJohn

    Mark Propst Guest

    Hi HJohn,
    not sure what the bigger picture is here, and I'm far from an expert but the
    following occurs to me just from your brief example...the examples I've seen
    on error handling seem to go something like:

    on error resume next
    Set Obj=thisdrawing.Dictionaries("DictionayName")
    If Err then
    'there wasn't a "DictionaryName" item in the collection so do
    whatever...
    flag = False '(for example)
    Err.Clear
    end if


    If you don't want to use that style of error handling and you want to check
    obj specifically, what about :

    If Obj is Nothing then Flag = False
    instead of:
    If Not Obj is Nothing then Flag = True

    just to eliminate the need to call two functions to do the work of one

    hth
    Mark

    then, but I get the error "Invalid use of object". This is necessary to
    check if a named dictionary exists or not.
     
    Mark Propst, Jan 16, 2004
    #3
  4. HJohn

    HJohn Guest

    Thanks Mark, I am using you first option. I don't know what happened but I was getting this "Invalid use of object" error. After, I restarted the computer and everything is fine now. Thanks again
     
    HJohn, Jan 16, 2004
    #4
  5. HJohn

    Mark Propst Guest

    Glad to help
    Best of luck on your project.
    Mark

    I was getting this "Invalid use of object" error. After, I restarted the
    computer and everything is fine now. Thanks again
     
    Mark Propst, Jan 16, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.