' Gambas class file Private aButtons[13] As Button ' Dim the array of controls Public Sub Form_Open() Dim i As Integer btnClose.Tooltip = ("Quit") Me.Center For i = 1 To 12 aButtons[i] = New Button(Me) As "Buttongroup" ' Create a new button in the array and store it in an action group With aButtons[i] .X = (i - Int((i - 1) / 3) * 3) * 60 - 30 .Y = Int((i - 1) / 3) * 60 + 170 .Width = 42 .Height = 42 .Font.Grade = 5 If i = 10 Then .Text = "*" Else If i = 11 Then .Text = "0" Else If i = 12 Then .Text = "#" Else .Text = i Endif End With Next End Public Sub Buttongroup_Click() ' This is an event of the action group. This event is fired if any of the buttons is clicked ' You see a list of available events if you type "Buttongroup_" ' Dim w As Integer tbNumber.Text = tbNumber.Text & Last.Text ' find out with LAST which button was clicked and hand its text over to TextBox ' w = Last.Width ' this would return the width of the last button ' Print w End Public Sub Buttongroup_Menu() ' Another event of the action group: Right-click on any of the buttons Message.Info(Subst(("You have clicked the button &1"), Last.Text)) End Public Sub btnClose_Click() If tbNumber.Text = "" Then Me.Close Else tbNumber.Text = "" Endif End Public Sub Form_KeyPress() If Key.code = Key.Esc Then Me.Close End Public Sub tbNumber_Change() If tbNumber.Text = "" Then btnClose.Tooltip = ("Quit") Else btnClose.Tooltip = ("Clear") Endif End Public Sub btnDial_Click() If tbNumber.Text = "" Then Message.Warning(("There is no number I could dial.")) Else Message.Info(("Dialing ") & tbNumber.Text) Endif End