Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Brain Cramp... this should be simple, but I'm going nuts

Brain Cramp... this should be simple, but I'm going nuts

Scheduled Pinned Locked Moved Visual Basic
help
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mike the Red
    wrote on last edited by
    #1

    Prototypical Code (class/method structure omitted):dim FG as ComObject dim someString as String = "Some String" FG = new ComObject Try FG.someMethod(someString) Catch ex as Exception msgbox("Error: " & ex.message & vbCrLf & "(FG is Nothing): " & (fg Is Nothing).toString) & vbcrlf & "(someString is Nothing): " & (someString Is Nothing).toString) End Try
    ------- The output I get is:

    Error: Object reference not set to an instance of an object.
    (FG Is Nothing): False
    (someString Is Nothing): False

    I was under the impression that if the "object reference [is] not set to an instance of an object", then that object "Is Nothing" should return True. Can someone set me straight, please, I'm going nuts trying to figure this one out.

    L C 2 Replies Last reply
    0
    • M Mike the Red

      Prototypical Code (class/method structure omitted):dim FG as ComObject dim someString as String = "Some String" FG = new ComObject Try FG.someMethod(someString) Catch ex as Exception msgbox("Error: " & ex.message & vbCrLf & "(FG is Nothing): " & (fg Is Nothing).toString) & vbcrlf & "(someString is Nothing): " & (someString Is Nothing).toString) End Try
      ------- The output I get is:

      Error: Object reference not set to an instance of an object.
      (FG Is Nothing): False
      (someString Is Nothing): False

      I was under the impression that if the "object reference [is] not set to an instance of an object", then that object "Is Nothing" should return True. Can someone set me straight, please, I'm going nuts trying to figure this one out.

      L Offline
      L Offline
      Len Miller
      wrote on last edited by
      #2

      Hi, Is it possible that inside FG.SomeMethod, something is trying to reference a null object? Can you step into the FG.SomeMethod code and see if it is happening INSIDE there? (side note, the first instance of "(fg Is Nothing).toString)" in your messagebox string should not have the paren at the end) - I just know because I tried to run the code. Thanks, -Len Miller "If I had eight hours to chop down a tree, I'd spend six sharpening my axe." -Abraham Lincoln

      M 1 Reply Last reply
      0
      • M Mike the Red

        Prototypical Code (class/method structure omitted):dim FG as ComObject dim someString as String = "Some String" FG = new ComObject Try FG.someMethod(someString) Catch ex as Exception msgbox("Error: " & ex.message & vbCrLf & "(FG is Nothing): " & (fg Is Nothing).toString) & vbcrlf & "(someString is Nothing): " & (someString Is Nothing).toString) End Try
        ------- The output I get is:

        Error: Object reference not set to an instance of an object.
        (FG Is Nothing): False
        (someString Is Nothing): False

        I was under the impression that if the "object reference [is] not set to an instance of an object", then that object "Is Nothing" should return True. Can someone set me straight, please, I'm going nuts trying to figure this one out.

        C Offline
        C Offline
        chrismerrill
        wrote on last edited by
        #3

        My best guess is that there is a variable in FG.someMethod that is causing the problem. Have you tried running your code in debug mode then stepping through line by line with the F11 key till you get to the line causing the error?

        M 1 Reply Last reply
        0
        • C chrismerrill

          My best guess is that there is a variable in FG.someMethod that is causing the problem. Have you tried running your code in debug mode then stepping through line by line with the F11 key till you get to the line causing the error?

          M Offline
          M Offline
          Mike the Red
          wrote on last edited by
          #4

          Unfortunately FG is a 3rd party COM object, so I can't debug it. But it sounds like I'm not going nuts - if FG is "not set to an instance of an object" then (FG Is Nothing) would evaluate True. Thanks for the help.

          1 Reply Last reply
          0
          • L Len Miller

            Hi, Is it possible that inside FG.SomeMethod, something is trying to reference a null object? Can you step into the FG.SomeMethod code and see if it is happening INSIDE there? (side note, the first instance of "(fg Is Nothing).toString)" in your messagebox string should not have the paren at the end) - I just know because I tried to run the code. Thanks, -Len Miller "If I had eight hours to chop down a tree, I'd spend six sharpening my axe." -Abraham Lincoln

            M Offline
            M Offline
            Mike the Red
            wrote on last edited by
            #5

            Good catch on the msgbox string - I missed that.:wtf: FG is a 3rd party COM object, so anything is possible inside it. Unfortunately, that also means I can't debug it. But it sounds like I'm not going nuts - if FG is "not set to an instance of an object" then (FG Is Nothing) would evaluate True. Thanks for the help.

            L 1 Reply Last reply
            0
            • M Mike the Red

              Good catch on the msgbox string - I missed that.:wtf: FG is a 3rd party COM object, so anything is possible inside it. Unfortunately, that also means I can't debug it. But it sounds like I'm not going nuts - if FG is "not set to an instance of an object" then (FG Is Nothing) would evaluate True. Thanks for the help.

              L Offline
              L Offline
              Len Miller
              wrote on last edited by
              #6

              Hmm. Too bad you can't debug the method. What I would do is check the docs of FG & FG.SomeMethod. Maybe the objects expects that you have already set a property to some object that it is trying to use. Or, maybe it expects that you may have already set some objects that it needs during creation. Like this: Dim FG as new ComObject(neededObject) Or this FG.NeededObject = neededObject Maybe THEN you can run FG.SomeMethod ??? Just a thought... Good luck Thanks, -Len Miller "If I had eight hours to chop down a tree, I'd spend six sharpening my axe." -Abraham Lincoln

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups