Referring controls with $variables

Post

Posted
Rating:
#1 (In Topic #560)
Regular
01McAc is in the usergroup ‘Regular’
The situation:
I placed a textbox control in the main form. The Tag of the textbox gets the name of another control in the same form.
  →  TextBox.Tag="DataComboView1"

When I try the following commands the compiler throws an error:
  →  Print Me(TextBox.Tag).Table
  →  Print ("DataComboView1").Table

Any idea how to refer to a control when I just have the name of a control in a string variable?

I know that MS-Acces supports it, e.g. Me($var).visible = True.
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
01McAc is in the usergroup ‘Regular’
Just found by chance on the internet https://lists.gambas-b…2016-February/056722.html the answer. The correct command is:
   → FMain.Controls["DataComboView1"].Table

Obviously Me doesn't support this.
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’

01McAc said

Just found by chance on the internet https://lists.gambas-b…2016-February/056722.html the answer. The correct command is:
   → FMain.Controls["DataComboView1"].Table

Obviously Me doesn't support this.

Me just stands for the class or module file in use

for a normal Form (FMain) it refers to the form and class file of the same name.
so   Me.Controls["DataComboView1"].Table  would work.

the IDE gives great clues as you type.
Pressing a bracket after your object Ie . FMain.Controls(  would show nothing , but using an angle bracket [ will show there are options using the angle brackets.

you can skip a whole lot of searching for answers just by trying different combinations of brackets ( ,  angle brackets [ , full stops .  and seeing what gives you options and what options you get :)

Bruce
Online now: No Back to the top
1 guest and 0 members have just viewed this.