Microsoft Small Basic

Program Listing: MDP504-3
' TextBox Sample
' Version 0.4 - using GraphicsWindow.KeyDown event
' Copyright © 2016-2017 Nonki Takahashi. The MIT License.
' Program ID MDP504-3

GraphicsWindow.Title = "TB 0.4"
Init()

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

Sub OnKeyDown
key = GraphicsWindow.LastKey
If key = "Return" Then
curTxt = Controls.GetTextBoxText(tbox)
Shapes.SetText(shp, "Hello, " + curTxt + "!")
Controls.SetTextBoxText(tbox, "")
EndIf
EndSub