[Gambas-user] how to place code into events of an array of buttons?

roberto.premoli at tiscali.it roberto.premoli at tiscali.it
Tue Feb 1 21:47:45 CET 2022


Il 01.02.2022 19:46 T Lee Davidson ha scritto:

> On 2/1/22 12:50, roberto.premoli at tiscali.it [1]wrote:
>
>>> Change Form_Open like this ' ... matrice_testo[0] = "A"
>>> matrice_testo[1] = "B" matrice_testo[2] = "C" matrice_testo[3] = 
>>> "D"
>>> matrice_testo[4] = "E" For n = 0 To 4 With btns[n] = New
>>> Button(FMain) As "btns" .Name = matrice_testo[n] End With Next ' 
>>> ...
>>> Public Sub btns_Click() Print Last.name End Regards Gianluigi
>> Thanks Gianluigi! there is a way to take also the index of button
>> pressed? because to have the index of button is necessary in other 
>> part
>> of the program, I tried - naively - to do "variabile = Last.index" 
>> bot
>> of course it does not work.
>
> If your matrice_testo and btns arrays are always kept in sync, you 
> could
> use the String[].Find method; eg.
> iIndex = matrice_testo.Find(Last.Name)
>
> Personally, I think I'd simply populate the button's Tag with its 
> index.
>
> -- Lee ----[ http://gambaswiki.org/wiki/doc/netiquette [2] ]----

matrice_testo and btns will be always in sync, yes.
you have my same idea, to use "tag" as "index".
i will do, even if it give me the idea to be less "elegant" than index.
But at the end, I need "it works" not "it is elegant" :-D
I also thanks the other folks keep interest in my question and give 
reply.
Thanks all folks!



Con Tiscali Mobile Smart 70 hai 70 GB in 4G, minuti illimitati e 100 
SMS a soli 7,99€ al mese http://tisca.li/Smart70




More information about the User mailing list