2014-01: Graphical
Make a simple graphical calculator.
Perhaps the user enters 2 numbers in 2 textboxes and then presses one of 4 buttons to +, -, *, / with the result given in a third textbox.
Crea una semplice calcolatrice grafica.
L’utente inserisce 2 numeri in 2 caselle di testo e poi preme uno dei 4 pulsanti con i simboli +, -, *, / e ottiene il risultato in una terza casella di testo.

GraphicsWindow.BackgroundColor="Black"
GraphicsWindow.Width =430
GraphicsWindow.Height =180
GraphicsWindow.Title ="Le 4 operazioni"
GraphicsWindow.DrawText(50, 50, "Input 1")
GraphicsWindow.DrawText(50, 80, "Input 2")
GraphicsWindow.DrawText(50, 110, "Output" )
tb1=Controls.AddTextBox(110, 50)
Controls.SetSize(tb1,160,25)
Controls.SetTextBoxText(tb1, 300)
tb2=Controls.AddTextBox(110, 80)
Controls.SetSize(tb2,160,25)
Controls.SetTextBoxText(tb2, 12)
tb3=Controls.AddTextBox(110, 110)
Controls.SetSize(tb3,160,25)
Controls.SetTextBoxText(tb3, "...")
b1=Controls.AddButton(" + ", 280, 50)
Controls.SetSize(b1,40,25)
b2=Controls.AddButton(" - ", 330, 50)
Controls.SetSize(b2,40,25)
b3=Controls.AddButton(" * ", 280, 80)
Controls.SetSize(b3,40,25)
b4=Controls.AddButton(" / ", 330, 80)
Controls.SetSize(b4,40,25)
Controls.ButtonClicked=ButtonClicked
Sub ButtonClicked
n1=Controls.GetTextBoxText(tb1)
n2=Controls.GetTextBoxText(tb2)
bb=Controls.LastClickedButton
If(bb = b1) Then
r=n1+n2
ElseIf(bb = b2) Then
r=n1-n2
ElseIf(bb = b3) Then
r=n1*n2
ElseIf(bb = b4) Then
r=n1/n2
Else
r="-- Errore --"
EndIf
Controls.SetTextBoxText(tb3, r)
EndSub