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

Martin Belmonte mbelmonte at belmotek.net
Tue Sep 8 20:23:53 CEST 2020


Hi Paolo.

Were a form with 3 labels and 1 button

stx[0] = control type, stx[1] =control name and finaly stx[2] =Text to 
put in text property

I suggest this code

Public Sub ControlStamp(stx As String[])

   Dim ct As Object
   Dim i As Integer
   Dim colex As New Collection

   If stx.Count = 3 Then
     Select stx[0]
       Case "TextBox", "ComboBox", "Label"
         For Each ct In Me.Controls
           If Object.Type(ct) = stx[0] Then
             colex.Add(ct, ct.Name)
           Endif
         Next
         If colex.Exist(stx[1]) Then
           colex[stx[1]].Text = stx[2]
         Endif
     End Select
   Endif

End

Note: this form below can break the flow of the program if you give a 
non-existent control name.

hlabel = Me[idName]

Regards.

El 6/9/20 a las 17:58, pinglix via User escribió:
>
> 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.
>
>
> What is the best way to do it ?
>
> I cannot find a Find() method by name that returns a reference to the 
> correct object.
>
> I can set them to the same Group but then what can I do with it ?
>
>
> Thanks,
>
> Paolo
>
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20200908/3976c038/attachment.htm>


More information about the User mailing list