Brain Cramp... this should be simple, but I'm going nuts
-
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): FalseI 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.
-
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): FalseI 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.
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
-
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): FalseI 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.
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?
-
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?
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.
-
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
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.
-
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.
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