[Gambas-user] how to write text in indexed list of labels

Jussi Lahtinen jussi.lahtinen at gmail.com
Mon Sep 7 01:14:25 CEST 2020


IF that is all you are going to do, then no reason to declare the obj.

Jussi

On Mon, Sep 7, 2020 at 12:12 AM Gianluigi <bagonergi at gmail.com> wrote:

>
>
> Il giorno dom 6 set 2020 alle ore 20:00 Gianluigi <bagonergi at gmail.com>
> ha scritto:
>
>>
>>
>> Il giorno dom 6 set 2020 alle ore 19:45 Benoît Minisini <g4mba5 at gmail.com>
>> ha scritto:
>>
>>> Le 06/09/2020 à 17:58, pinglix via User a écrit :
>>> > Hi,
>>> >
>>> > I have 200 Label components on a form with name Label1, Label2 ....
>>> > Label200 and I need to change the Text property of one of them through
>>> > an integer index.
>>>
>>> Window (and so Form) objects can be used as a collection of its children
>>> controls indexed by name.
>>>
>>> I.e. : MyForm["Label" & Index] will return the Label<Index> control.
>>>
>>> But you should better create such many labels dynamically and store the
>>> references in your own array of Labels.
>>>
>>
>> Yes, I apologize, mine is not good Gambas code, don't use it  :-(
>>
>
> Hi Benoit,
>
> just one question, is this code acceptable or will I be burned at the
> stake for apostasy?
>
> Public Sub Button1_Click()
>
>   Dim obj As Object = Me["Label" & $iIndex]
>
>   obj.text = "Pippo"
>
> End
>
> Regards
> Gianluigi
>
> P.S. Naturally accompanied by the advice to study Last, Tag, Action and
> company
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20200907/c3e72551/attachment.htm>


More information about the User mailing list