Addressing Control arrays?

I have an array of checkboxes, chkRelays(0 to 15) defined as a control set member of “chkRelays”

I’m trying to set them to the last saved state from a function called when the program loads that loads a config file (window load event), but I can’t figure out how to address them in code.

(i= integer loop counter)

winmain.chkRelays(i).Value = True

That bombs with an error telling me “this item does not exist” pointing to chkRelays(i), autocomplete only works with “winmain.chkRelays.” and gives me pop, append, remove, shuffle, specifying the index () doesn’t seem to work so it seems I’m doing something wrong here.

Searched around a bit in the pdf’s but nothing comes up about how to address control arrays.

Simple question, but what’s your actual code for declaring i? Should be:
dim i as integer

If you type to the point of:
winmain.chkRelays(i).

Will it autocomplete from there? Should have a list of variables for the checkboxes.

Yeah that was just to show that “i” was declared as integer, declared as your example.

winmain.chkRelays(i).

or

winmain.chkRelays(1).

Just bombs and tells me “this item does not exist”

Only “winmain.chkRelays.” gives me autocomplete, but not things like “.value”, just append, pop etc…

Maybe the control array is not available yet in window open event?

It should be available during open unless you’re creating it dynamically (which you aren’t). Did you set it up properly in the IDE? It’s a few more steps than it used to be so there’s a chance something went wrong there.

Separately, did you declare a local variable with the same name for an array of some sort in that function? Might just help to post the entire functions code (using the code tags on the forum).

Refer to User Guide Book 2: User Interface, Chapter 2: Desktop, Section 16: Control Sets and Dynamic Controls. Control Arrays are now referred to as Control Sets in order to eliminate confusion caused by them not actually being arrays.

Thanks for the manual referral Paul, I’ll have a sit down and read up on that tonight, and thanks to Tom also, I’ll check the manual.

Those pesky pdf’s are hard to search, esp. when you don’t know what your looking for :smiley:

I’m getting some serious oldschool vb vibes from xojo, which was why I was treating it as a control array, even though it was years ago I last touched vb.

That’s a good thing btw :slight_smile: