This article explains the Controls object in Small Basic.  In addition, the other controls are also explained.

What Are Controls?

Small Basic gives us the following three controls.  These controls can be created with the Controls object.

  • Button
  • Text input box
  • Multi-line text input box

How to Use Controls

This is a sample to use three controls.

1.GraphicsWindow.Title = "Dictionary" = 598 = 428
4.GraphicsWindow.Width = gw
5.GraphicsWindow.Height = gh
6.GraphicsWindow.BackgroundColor = "LightGray"  ' form color
7.GraphicsWindow.BrushColor = "Black"           ' font color
8.GraphicsWindow.FontName = "Arial"   ' second font candidate
9.GraphicsWindow.FontName = "MS Reference Sans Serif"
10.GraphicsWindow.DrawText(10, 14, "Word")
11.wordBox = Controls.AddTextBox(50, 10)
12.findBtn = Controls.AddButton("Search", 220, 8)
13.defBox = Controls.AddMultiLineTextBox(10, 40)
14.Controls.SetSize(defBox, gw - 20, gh - 50)
15.Controls.ButtonClicked = OnButtonClicked
16.Sub OnButtonCLicked
17.  word = Controls.GetTextBoxText(wordBox)
18.  def = Dictionary.GetDefinition(word)
19.  Controls.SetTextBoxText(defBox, def)

Controls Object

The Controls object has the following members. Details of the Controls object are described in the Reference Document.


  • LastClickedButton (for button)
  • LastTypedTextBox (for text box and multi-line text box)


  • ButtonClicked (for button)
  • TextTyped (for text box and multi-line text box)


  • AddButton (for button)
  • AddMultiLineTextBox (for multi-line text box)
  • AddTextBox (for text box)
  • GetButtonCaption (for button)
  • GetTextBoxText (for text box and multi-line text box)
  • HideControl 
  • Move
  • Remove
  • SetButtonCaption (for button)
  • SetSize
  • SetTextBoxText (for text box and multi-line text box)
  • ShowControl

New Line in Multi-Line Text Box

Text in a multi-line text box has multiple lines separated with new line codes.  If the program runs in desktop (local), then the new line code is CR+LF.  CR (carriage return) is 0x0D and LF (line feed) is 0x0A.  And if the program runs in browser with (remote), then the new line code is CR.  These are about input from keyboard with [Enter] key.

If you copy (or cut) and paste a multi-line text from other program (software) to a multi-line text box in a Small Basic program, original new line code will be kept.  That may CR, LF or CR+LF.

You can confirm about new lines with Text Dump 0.21 KPS036-0.

Extra Controls

Sample Programs

There are many controls in other programming languages.  Following samples show how to create such extra controls in Small Basic.

  • Check Box (GZL896) - Check box control is an on/off switch.  Details are described in an article Small Basic: How to Make a Check Box.
  • Radio Button (SZW634) - Radio buttons are controls to select one from a group.
  • Color Slider (HWD964) - Slider control is to get a value from a range.
  • Progress Bar (MBB966-0) - Progress bar shows percentage.


  • LitDev Extension - LDControls object has TreeView, RichTextBox, WebBrowser, ListBox, ComboBox, CheckBox, RadioButtons, MediaPlayer, Slider, ProgressBar, PasswordBox, DocumentViewer, Menu and ListView.

See Also

Other Resources

Other Languages