[Gambas-user] Phone center

Benoit Minisini gambas at ...1...
Mon Feb 9 14:44:45 CET 2004


On Sunday 08 February 2004 19:45, Rob wrote:
> I tried to intersperse my code with your own, but it got hard to
> understand.  So here's what I'd do.

I add my remarks :-)

>
> First off, unless I'm mistaken, there's no way to find out the
> name of a control on a form in Gambas at runtime, 

That's true.

> nor is there a way to determine that it's a textbox and not a button.  

That's false! Use Object.Type(...) to get the object datatype.

> So you will have to use a different set of tags for your textboxes than
> you do for your buttons.  Let's say you use 0, 1, 2, 3 for your
> buttons and t0, t1, t2, t3 for your textboxes.  I'm assuming
> this is in the click event of the group of buttons whose
> captions you want assigned to their respective textboxes.
>
> This is actual working code that I just tested in gambas 0.82.  I
> used j instead of i as an iterator because originally I still
> had your for i = 0 to 3 in there but it turned out to be
> unnecessary.
>
> PUBLIC SUB mybuttons_Click()
>
>   DIM j AS Object
>   FOR EACH j IN ME.children
>     IF j.tag = "t" & LAST.tag THEN j.text = LAST.text
>   NEXT
>
> END
>
>
> Rob
>
>

You can put anything you want in a Tag, not only a string. You can put an 
object reference for example. It can helps.

Elsewhere, the textboxes should be created dynamically. This way you can add 
telephones and lines without modifying your program interface.

DIM nTextBoxes AS Integer
DIM MyTextBoxes AS NEW Object[]
DIM hTextBox AS TextBox

FOR I = 0 TO nTextBoxes - 1
  hTextBox = NEW TextBox(MyForm)
  ...
  MyTextBoxes.Add(hTextBox)
NEXT

Or something like that...

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...





More information about the User mailing list