Visual Basic: String Addition – Piecing Text Together

Posted: January 31st, 2012 | Author: | Filed under: Visual Basic Tutorial (Series) | No Comments »

In the last Visual Basic: String, Integer and Double tutorial, we were looking at developing a calculator to better understand variables and data types. However the calculator looks very messy, so let’s just clean the calculator up and learn a little bit more.

 

 

 

 


Therefore we’ll be tidying the screen up and we’ll do this by displaying the equation it was calculating followed by the results too. We want to print out the value of variables a and b and the value of earch result. Here is how:

Console.Write(a. ToString() + ” + ” + b.ToString ())
Console.WriteLine(” = ” + c.ToString)

The code above coloured red is to print out the value of variable (a)
The + ” + ” + in the above code is the + sign which means we add to pieces of text.
Print out the value of variable B is followed.
Print out the value of variable C is followed by this.

If you are struggling then you haven’t understood the tutorial. Think about the above and think how you can integrate the above code to work for all equations.

Next we look at Visual Basic String Padding & Aligning Text

Visual Basic Tutor



Leave a Reply