On Wednesday 27 January 2010, Kadaitcha Man wrote: > 2010/1/27 Fiddler63 <mx4...@gmail.com>: > > > In gambas I get an error if I give more that one button the same name. > > How do I index a row of buttons in Gambas ? > > You don't. Gambas is not VB; it does not suppor, and rightly so, > arrays of control objects in the way that VB does; even the more > modern .NET revisions do not do it the way VB does. If you want more > than one object to do the very same thing then you use the control's > Group property. > > If you need to know what item in the group was selected then, for > example, you use the Tag property. Or, perhaps the Caption property: > > Public Sub mnuEdit_Click() > > Select Case mnuEdit.Caption > Case $MNU_ITEM_EDIT_IDENTITY > [...] > Case $MNU_ITEM_EDIT_OPTIONS > [...] > Case $MNU_ITEM_NEW_OPTIONS > [...] > End selct > > End > > In the above code example, one menu item has three functions. The > function is determined by the context of the code. >
A other example: set for all the buttons that 'group' to the the same name (i.e. 'Calculator') and set the 'Tag' property to what what the key represents. Public Sub Calculator_Click() Select Case Last.Tag Case '-' total = memory + number Case '+' total = memory + number Case '=' Display.text = total Default number = (number * 10) + Last.Tag End select End You can use the caption but if you publish it in multiple languages then 'Clear' is 'Wissen' in Dutch. The .Tag can be used as unique identification of the key pressed and set for ever by you. This way the code behind stay for ever the same (till bug found :) ). Best regards, Ron_1st -- 111.111111 x 111.111111 = 12345.678987654321 -- ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user