Microsoft Small Basic

Program Listing: MDP504-4
' TextBox Sample
' Version 0.5 - using a button and the key down event
' Copyright © 2016-2017 Nonki Takahashi. The MIT License.
' Program ID MDP504-4

GraphicsWindow.Title = "TB 0.5"
Init()

Sub Init
GraphicsWindow.Width = 220
GraphicsWindow.Height = 100
GraphicsWindow.BrushColor = "Black"
tbox = Controls.AddTextBox(10, 10)
Controls.AddButton("OK", 180, 8)
shp = Shapes.AddText("")
Shapes.Move(shp, 10, 40)
Controls.ButtonClicked = OnButtonCLicked
GraphicsWindow.KeyDown = OnKeyDown
EndSub

Sub OnButtonClicked
txt = Controls.GetTextBoxText(tbox)
Shapes.SetText(shp, "Hello, " + txt + "!")
EndSub

Sub OnKeyDown
key = GraphicsWindow.LastKey
If key = "Return" Then
OnButtonClicked()
EndIf
EndSub