Microsoft Small Basic for Beginners
Microsoft Small Basic (2008) is a deliberately tiny language with about 14 keywords, aimed at children and first-time programmers.
36.1 What it is
Microsoft Small Basic (2008) is a deliberately tiny language with about 14 keywords, aimed at children and first-time programmers. It runs on the .NET Framework (desktop IDE for Windows) and in a browser version, and features IntelliSense-style help, a Turtle, and simple objects: TextWindow, GraphicsWindow, Turtle, Shapes, Math, Program, Timer, Sound, File, Array. Programs can be "graduated" (exported) to Visual Basic .NET.
36.2 Syntax overview
Keywords: If, Then, Else, ElseIf, EndIf, For, To, Step, EndFor, While, EndWhile, Sub, EndSub, Goto, And, Or. All variables are global; there are no types (everything is a "primitive" value — number or text).
TextWindow.WriteLine("What is your name?")
name = TextWindow.Read()
TextWindow.WriteLine("Hello, " + name + "!")
For i = 1 To 5
TextWindow.WriteLine(i + " squared is " + (i * i))
EndFor
age = 15
If age >= 13 And age <= 19 Then
TextWindow.WriteLine("Teenager")
ElseIf age < 13 Then
TextWindow.WriteLine("Child")
Else
TextWindow.WriteLine("Adult")
EndIf
count = 0
While count < 3
count = count + 1
EndWhile
colors[1] = "red" ' arrays use square brackets and need no declaration
colors[2] = "green"
TextWindow.WriteLine(Array.GetItemCount(colors))36.3 Turtle graphics
Turtle.Speed = 9
For side = 1 To 36
For i = 1 To 4
Turtle.Move(100)
Turtle.TurnRight()
EndFor
Turtle.Turn(10)
EndFor36.4 Events and subroutines
Subroutines take no parameters and return no values — they communicate through global variables, just like GOSUB in classic BASIC. Once learners outgrow this, QB64-PE or VB.NET is the natural next step.
GraphicsWindow.Title = "Click to draw circles"
GraphicsWindow.MouseDown = OnMouseDown ' attach an event handler
Sub OnMouseDown
GraphicsWindow.BrushColor = GraphicsWindow.GetRandomColor()
x = GraphicsWindow.MouseX
y = GraphicsWindow.MouseY
GraphicsWindow.FillEllipse(x - 20, y - 20, 40, 40)
EndSub