[Gambas-user] dateadd

Rob sourceforge-raindog2 at ...94...
Fri Jun 24 02:16:38 CEST 2005


On Thursday 23 June 2005 18:36, Jeff Johnson wrote:
>         textbox1.Text = hbutton.name
>         i = hbutton.name
>         hbutton(i).delete

Well, here are the problems with that.

1. There is no "name" property for anything in Gambas.  I hope someday 
Benoit will change his mind about this ;)  Of course, in the example 
you give, the .name property in VB would have returned "hButton" so 
you would have been trying to delete "hButton(hButton)".

2. Adding multiple controls with the same name does not result in a 
control array being created in Gambas.

Here is how I would write that routine (obviously not checked for 
syntax):

     DIM hButtons as NEW Object[]
     ' You probably want to make hButtons public and initialize it
     ' in your Form_Open before doing any of this.

     DO WHILE TRUE
        hButton = NEW Button(ME) AS "Station"
        hButton.X = rData!DLongitude
        hButton.Y = rData!DLatitude
        hButton.Raise
        hButton.Text = rData!Station
        hButton.Width = 75
        hButton.Height = 7
        hButton.Font.Size = 6
        hButton.Picture = Picture[rData!Icon]
        hButton.Tag = rData!Statusline
        hButtons[rData!Station] = hButton
        ' You didn't mention which field contained the name of
        ' the button, so substitute that field for rData!Station
        ' here and below.
        mCount = mCount + 1

        IF rdata!station = "THORN" THEN
           textbox1.Text = rData!Station
           hbuttons[rData!Station].delete
        END IF

        IF mCOunt = rData.Count THEN
           BREAK
        ENDIF
        rdata.MoveNext
     LOOP

When you later wish to delete buttons, iterate through the hButtons 
array and check in the database to see if the button should be 
deleted.

Rob






More information about the User mailing list