Small Basic – Combining Strings and Variables


Combining Strings and Variables

Be careful when you want to display variable contents as strings! These two statements are different:

TextWindow.WriteLine(“x”)

TextWindow.WriteLine(x)

   

The first statement displays the literal string “x” on the screen. The second statement displays the value of the variable x.

You can mix strings and numbers using the plus sign. For example, let’s say x = 7 and y = 5 in this statement:

TextWindow.WriteLine(“What is “ + x + “+” + y + “?”)

  

This displays the string “What is 7+5?” on the screen.

 

Head to http://blogs.msdn.com/SmallBasic to download Small Basic and learn all about it!

 

Have a Small and Basic day!

   – Ninja Ed & Majed Marji

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