Array of control

bdiscount

Active Member
Licensed User
I am wishing for the capability of arrays of controls I know about the control keyword etc but thats a lot of book keeping for me.
Is it possible with net?
 

Cableguy

Expert
Licensed User
Longtime User
What wrong with GETCONTROLS?

From the Basic4ppc help file:

Returns an array with the names of all the controls that belong to the specified control.
Syntax: GetControls (Control Name)
Pass an empty string "", to get all the controls available.
 

klaus

Expert
Licensed User
Longtime User
Hi Paulo,

With the GetControl keyword you get an array of the Controls belonging to another Control.

The wish of bdiscount is to have for example an array of TextBoxes like
TextBox(1)
TextBox(2)
TextBox(3)
etc

and have acces to the properties like
TextBox(1).Text
TextBox(2).Text
etc.

he would also use it also like
For i=1 to 3
TextBox(i).Text = "Text"&i
Next

This is different from the GetControls keyword.

Best regards.
 

Cableguy

Expert
Licensed User
Longtime User
Hi Paulo,

With the GetControl keyword you get an array of the Controls belonging to another Control.

The wish of bdiscount is to have for example an array of TextBoxes like
TextBox(1)
TextBox(2)
TextBox(3)
etc

and have acces to the properties like
TextBox(1).Text
TextBox(2).Text
etc.

he would also use it also like
For i=1 to 3
TextBox(i).Text = "Text"&i
Next

This is different from the GetControls keyword.

Best regards.

I just did some simple (simpistic actualy) Test..

added 6 Textboxes, 6 CheckBoxes and 6 Buttons in the designer, to form1...

Then I added this code:
B4X:
Sub Globals
   'Declare the global variables here.
Dim b(1)
End Sub

Sub App_Start
   Form1.Show
   B()=GetControls("")
   For i =0 To ArrayLen(B())-1
   Control(B(i)).Text="New Txt"
   Next
End Sub

And ALL controls got their text prop chnged to the value I mentioned...

In what way is this diferent from what you think he is aiming for, Klaus?
GetControls("") get an aray of ALL the controls contained in a Module, with their module prefixe... includng the forms...
 

klaus

Expert
Licensed User
Longtime User
In your example, ALL controls are changed.

But the way I understoud bdiscount's wish is that he could define an array of let's say 6 TextBoxes, another array of 5 RadioButtons and so on, but he doesn't want to have all the form's controls in one array.

I had used Control arrays in Visual Basic.

Anyway, for me, as Erel said, the Control keyword allowing the same is satisfactory. I just wanted to clarify the subject.

Best regards.
 

bdiscount

Active Member
Licensed User
arrays

Klaus is right about what I want. At my age it is a lot easier to keep track of a direct array with out using control. But thats a problem with age and memory going, too old to dev. for sale but ok for personal work. thanks for all the trials

PS I got the idea from VB etc. I used to dev in C++,VB, Masm
 
Top