Microsoft Small Basic

Program Listing: XNL147
' For.
' Prints 1 through 10.
For i = 1 to 10
TextWindow.Write(i + " ")
EndFor
TextWindow.WriteLine("")

' For with Step.
' Prints 1, 3, 5, 7, 9 only.
For i = 1 To 10 Step 2
TextWindow.Write(i + " ")
EndFor
TextWindow.WriteLine("")

' While.
' Prints 1 through 9 only.
i = 1
While i < 10
TextWindow.Write(i + " ")
i = i + 1
EndWhile
TextWindow.WriteLine("")

' If only.
If Clock.Year = 2010 Then
TextWindow.WriteLine("The year is 2010.")
EndIf

' If/Else.
If Clock.Year = 2010 Then
TextWindow.WriteLine("The year is 2010.")
Else
TextWindow.WriteLine("The year is not 2010.")
EndIf


' If/ElseIf.
If Clock.Year = 2010 Then
TextWindow.WriteLine("The year is 2010.")
ElseIf Clock.Year = 2009 then
TextWindow.WriteLine("The year is 2009.")
Else
TextWindow.WriteLine("The year is neither 2009 nor 2010.")
EndIf