|
-
Apr 18th, 2008, 10:10 AM
#1
Thread Starter
PowerPoster
[RESOLVED] if an obejct exist
i'm using visual baisc 6.
how can i see if one object exist?
thanks
-
Apr 18th, 2008, 12:07 PM
#2
Re: if an obejct exist
There are lots of different kinds of objects. What are you looking for?
-
Apr 18th, 2008, 12:30 PM
#3
Thread Starter
PowerPoster
Re: if an obejct exist
 Originally Posted by Hack
There are lots of different kinds of objects. What are you looking for?
i'm sorry it's a shape control.
i need a line like these one:
if "shpimage(i).exist=false" then load shpimage(i)
thanks
Last edited by joaquim; Apr 18th, 2008 at 03:15 PM.
-
Apr 30th, 2008, 04:34 PM
#4
Thread Starter
PowerPoster
Re: if an obejct exist
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
-
Jul 31st, 2008, 11:38 AM
#5
Re: if an obejct exist
Code:
If Not (shpimage(i) = Nothing) Then
You were right the 1st time, you need to evaluate the object 1st usually.
-
Jul 31st, 2008, 01:44 PM
#6
Thread Starter
PowerPoster
Re: if an obejct exist
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
-
Jul 31st, 2008, 01:55 PM
#7
Re: if an obejct exist
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...
-
Jul 31st, 2008, 02:01 PM
#8
Re: if an obejct exist
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:
-
Jul 31st, 2008, 02:04 PM
#9
Thread Starter
PowerPoster
Re: if an obejct exist
 Originally Posted by alex_read
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.
thank you very much
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|