user322076
user322076

Reputation:

VB6 type mismatch error

I am getting the following type mismatch error on the following

   IF obj.propery THEN
    ...
    END IF

the code I am using is on visual source safe and when other developers run the same project the code runs with no error. The property is actually a string which is where the problem could be. When I debug and test the property i.e.

?obj.propery = True

no errors are thrown which is a bit strange. If I place the cursor over the property it says "True". I have done a bit of searching on the matter and have found that this may have something to do with OPTION STRICT, however I have the same version of the code as the other developers and OPTION STRICT is not OFF, it hasn't been altered in the code at all. Are there any other settings that could affect this execution of code at run time?

Upvotes: 3

Views: 14346

Answers (4)

Bob Bowie
Bob Bowie

Reputation: 31

It strikes me that there could be an entirely different reason for your Type Mismatch error, especially as you are accessing an object property. I've experienced this error when I have, for some reason, been pointing at a different DLL to that registered. You will find with VB that it registers a DLL "on the fly" when you build it, so you may end up accessing the code somewhere that you did not expect. This may not be the problem in your case, but it is worth exploring.

Upvotes: 3

wqw
wqw

Reputation: 11991

So you are sure this is not the case of a boolean being Vrai?

Upvotes: 1

user322076
user322076

Reputation:

This was nothing to do with VB6, it was to do with XP Mode and using my user account from another domain as opposed to XPMUser. When I use XPMUser the application runs this is very odd and I am not sure why this is. If anyone has the reason I would love to hear.

Upvotes: 2

Rob Cowell
Rob Cowell

Reputation: 1618

I'd be inclined to be more explicit in your IF condition

IF isempty(obj.property) = false AND isnull(obj.property) = false

BUT

it would be prudent to check that obj isn't null first, before you start accessing its properties....

Upvotes: 0

Related Questions