i'm using visual baisc 6.
how can i see if one object exist?
thanks
Printable View
i'm using visual baisc 6.
how can i see if one object exist?
thanks
There are lots of different kinds of objects. What are you looking for?
i'm sorry it's a shape control.Quote:
Originally Posted by Hack
i need a line like these one:
if "shpimage(i).exist=false" then load shpimage(i)
thanks
if i put these line of code:
if sprite1.collision.precision=true then
msgbox "Precisioon collision is activated"
else
msgbox "Precision collision isn't activated"
end if
my question is: if these property doesn't exist, i recive an error, what value of these property have?
i need to know these for one property/method that i'm trying to do.
thanks
You were right the 1st time, you need to evaluate the object 1st usually. :)Code:If Not (shpimage(i) = Nothing) Then
now i know how see if 1 object exists. but can i see, like you sod in 2nd, if the property exists or have that value?
thanks
So you are talking about evaluating/enumerating which properties and object type might have? There's no way to retreive this information at runtime which I know fo through VB prior to .Net (so, within any COM applications), however if you have the possiblity to use .Net instead, this introduces a reflection framework which does allow this functionality.
The only other advice I could give which might be of help, was if you knew the property name, but didn't know it's type, you could use the "TypeOf" keyword in order to evaluate the type of the property, then based upon this, call the relevant code to check whether it's value existed - i.e. if the property type was a string, you could perform a check for an empty string (""), if the type was an object, you could perform a check to see whether the type was equal to a nothing (null) value - as above. Again this would require you knowing the property name in the 1st place though...
I realise that might not have been of much help to you, but the runtime would throw an error if you attempted to call a property which did not exist on an object. You could perform a dirtier, unprofessional, yet workable approach involving error trapping, but I believe this would be the only way you could check a property exists in a pre-.Net VB version. This might also be of some help to you:
Code:On error goto PropertyDoesntExist
If Not (object.property = nothing) Then
' Property exists, use it here
End If
PropertyDoesntExist:
is what i need.Quote:
Originally Posted by alex_read
thank you very much