Microsoft Small Basic

Program Listing: ZSP643
' Sample Code for Operators

' Unary Operator ----------
' Sign Operator
a = 3
TextWindow.Write("-a = ")
TextWindow.WriteLine(-a) ' - (minus)

' Binary Operators ----------
' Substitution Operator
b = a ' = (substitute)
TextWindow.Write("b = ")
TextWindow.WriteLine(b)

' Arithmetic Operators
TextWindow.Write("a + b = ")
TextWindow.WriteLine(a + b) ' + (add)
TextWindow.Write("a - b = ")
TextWindow.WriteLine(a - b) ' - (subtract)
TextWindow.Write("a * b = ")
TextWindow.WriteLine(a * b) ' * (multiple)
TextWindow.Write("a / b = ")
TextWindow.WriteLine(a / b) ' / (divide)

' Comparison Operations
If a = b Then ' = (equal to)
TextWindow.WriteLine("a = b")
EndIf
If a < b Then ' < (less than)
TextWindow.WriteLine("a < b")
EndIf
If a > b Then ' > (greater than)
TextWindow.WriteLine("a > b")
EndIf
If a <= b Then ' <= (less than or equal to)
TextWindow.WriteLine("a <= b")
EndIf
If a >= b Then ' >= (greater than or equal to)
TextWindow.WriteLine("a >= b")
EndIf
If a <> b Then ' <> (not equal to)
TextWindow.WriteLine("a <> b")
EndIf

' Logical Operators
If (5 <= a) And (a <= 10) Then ' And
TextWindow.WriteLine("(5 <= a) And (a <= 10)")
EndIf
If (a < 5) Or (10 < a) Then ' Or
TextWindow.WriteLine("(a < 5) Or (10 < a)")
EndIf

' Text Operator
TextWindow.WriteLine(a + " ^ 2 = " + Math.Power(a, 2)) ' + (concatenate)