Introduction: Small Basic Code
TextWindow.WriteLine("Enter the length of one side of square")
a = TextWindow.ReadNumber()
TextWindow.WriteLine("Enter the number 1 to find perimeter,number 2 for area and for both enter number 12")
b = TextWindow.ReadNumber()
If b = 1 Then
TextWindow.WriteLine("The perimeter is" +a*4)
ElseIf b = 2 then
TextWindow.WriteLine("The area is" +a*a)
ElseIf b = 12 then
TextWindow.WriteLine("The area is" +a*a)
TextWindow.WriteLine("The perimeter is" +a*4)
Else
TextWindow.WriteLine("Enter a valid entry")
EndIf
The code which is written above is of Microsoft Small Basic. This code is very special for me because this was the first-ever code I have written.
Step 1: Line 1 Explanation
TextWindow.WriteLine("Write here the text which you have to print") This is the format used for printing some text So, I have written the instruction for inputting the one side of the square.
Step 2: Line 2 Explanation
Variable Name = TextWIndow.ReadNumber() This is the format used for assigning a variable for inputting a number So, I have assigned variable A for inputting the side of the square.
Step 3: Line 3 Explanation
In this line, I am printing instructions for what you have to find area, perimeter or both.
Step 4: Line 4 Explanation
In this line, I am assigning Variable B for inputting a number to find what the user wants to find.
Step 5: Line 5 Explanation
The If and Then the command is used for taking decisions So, I have written if b is equal to 1 then print perimeter = a*4.
Step 6: Line 6 Explanation
The ElseIf command is used if the first statement does not satisfy then take this decision. So, I have written if b is equal to 2 then print area = a*a
Step 7: Line 7 Explanation
In this line, I am again using ElseIf. So, I have written if b is equal to 12 then print perimeter = a*4 and area = a*a.
Step 8: Line 8 Explanation
The Else command is used if any statement does not satisfy. So, if anyone does not enter a valid entry it prints Enter a valid entry.
Step 9: Line 9 Explanation
The EndIf statement is used for ending the code. So, I have written this to end the program.
Step 10: Ready
The code explanation is done, I have it might help you to write your program on small basic too.





