Small Basic – Goto Loops


Goto statements were first used for loops; try out the example code below. And we’ll also show you the output.

 

Copy and paste this program into Small Basic:

‘ Uses the Goto keyword to create a loop

x = 1

Start: ‘ A label named Start marks this line of the progarm

TextWindow.WriteLine(x)

x = x + 1

If (x <= 5) Then

    Goto Start

EndIf 

  

Output:

1

2

3

4

5

 

You can create loops this way, but most programmers don’t. Small Basic has two statements (For and While) that you’ll use for loops instead. 

 

Small and Basically yours,

   – Majed Marji & Ninja Ed

Comments (1)

  1. Computers Today (part 1 of 6)

    blogs.msdn.com/…/computers-today.aspx

    …..

    CS SPOTLIGHT: Girls in computer programming… why it matters!!!

    blogs.msdn.com/…/cs-spotlight-girls-in-computer-programming-why-it-matters.aspx

    Computational Thinking – Videos & Papers by Jeannette Wing

    blogs.msdn.com/…/computational-thinking-videos-amp-papers-by-jeannette-wing.aspx

Skip to main content