how to determine if control exists?

In this case I’ve got a container control, lets call it “X”, created by a button (“A”). When another button (“B”) is pressed X should no longer be visible.

Sometimes when B is pressed, X will not yet exist (conserving memory). I want to able to add a line in B that determines whether X exists before trying to act on it. Without this, I get a “does not exist” error.

should be easy, but …

thanks for your input

Compare “X” to Nil:

If X <> Nil Then ' X exists End If

Thanks, but

if o <> nil then o.visible = false

failed (This item does not exist). ok … it’s really “o”

the first “o” is highlighted in the error message.

Where are you declaring “o”? You need to have a reference (even if it’s Nil) to the object before you can access it.

that’s the point, I only want it created if I’m going to use it. When I move from it, it should disappear. However, pressing B will occur when “o” doesn’t exist.

the programming is basically, press B and if “o” exists then turn it off.

Or else, I could have a number of unused controls hanging out in the memory (wouldn’t that slow down the web page?)

If you’re creating it with something like

dim o as myContainer o = new myContainer
then “o” isn’t going to be available anywhere else in the program. Make “o” a property of the window, so you can test it for nil.

ok got it. made “o” a property. then used o = new containerOptions in the routine to show it.

in the close bit I used if o <> nil then o.visible

thanks all