# How to add • ### Question

• This is a very basic (I hope) question but I'm trying to type

textwindow.writeline("3+4 = " + 3+4)

and the answer given is 34.

OK, so how do I do adding and subtracting?

Is there a nice easy to read glossary anywhere?

Thanks,

Davyp314

Thursday, May 24, 2018 3:48 PM

• Small Basic uses the + operator to concatenate strings, or add numbers depending on the context.  It also works left to right.

"3+4 = " + 3+4

First "3+4 = " is considered a string, not a number,

Then you add 3 (+ 3).  This is adding a number to a string , the result is a string

Finally add another number to the string to get the final string output "3+4 = 34".

One thing you can do is use brackets, these will be done first, so the following works as hoped.

textwindow.writeline("3+4 = " + (3+4))

Note, the following also works since the numbers are added first before the result is considered a string

textwindow.writeline(3 + 4 + "=3+4")

• Edited by Thursday, May 24, 2018 7:24 PM
• Proposed as answer by Thursday, May 24, 2018 8:08 PM
• Marked as answer by Sunday, June 17, 2018 11:17 AM
Thursday, May 24, 2018 7:21 PM

### All replies

• Try following code

```totalvalue = 3 + 4;
textwindow.writeline("3+4 = " + totalvalue)```

Gaurav Khanna | Microsoft MVP | Microsoft Community Contributor

Thursday, May 24, 2018 5:30 PM
• Small Basic uses the + operator to concatenate strings, or add numbers depending on the context.  It also works left to right.

"3+4 = " + 3+4

First "3+4 = " is considered a string, not a number,

Then you add 3 (+ 3).  This is adding a number to a string , the result is a string

Finally add another number to the string to get the final string output "3+4 = 34".

One thing you can do is use brackets, these will be done first, so the following works as hoped.

textwindow.writeline("3+4 = " + (3+4))

Note, the following also works since the numbers are added first before the result is considered a string

textwindow.writeline(3 + 4 + "=3+4")

• Edited by Thursday, May 24, 2018 7:24 PM
• Proposed as answer by Thursday, May 24, 2018 8:08 PM
• Marked as answer by Sunday, June 17, 2018 11:17 AM
Thursday, May 24, 2018 7:21 PM