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.
Referring controls with $variables
Re: Referring controls with $variables
Just found by chance on the internet https://lists.gambas-basic.org/pipermai ... 56722.html the answer. The correct command is:
--> FMain.Controls["DataComboView1"].Table
Obviously Me doesn't support this.
--> FMain.Controls["DataComboView1"].Table
Obviously Me doesn't support this.
- BruceSteers
- Posts: 1563
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Referring controls with $variables
Me just stands for the class or module file in use01McAc wrote: ↑Tuesday 26th January 2021 2:35pm Just found by chance on the internet https://lists.gambas-basic.org/pipermai ... 56722.html the answer. The correct command is:
--> FMain.Controls["DataComboView1"].Table
Obviously Me doesn't support this.
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
If at first you don't succeed , try doing something differently.
BruceS
BruceS