Why is output to text screen wrong when using leading spaces

Darrel Wood 21 Reputation points
2021-03-05T06:29:24.63+00:00

' Initialize the Array
For i = 1 To 9
hold[i] = i
TextWindow.WriteLine(" "+i+" "+hold[i]) ' spaces and i not printed, hold[ i ]get multiplied by 2.
TextWindow.WriteLine("-"+i+"-"+hold[i]) ' replaced spaces with "-", works as intended.
EndFor
TextWindow.WriteLine("")

'having trouble with leading spaces, please help! 'thanks

Small BASIC
Small BASIC
A programming language created by Microsoft that serves a stepping stone for beginners from block-based coding languages to more complex text-based languages.
280 questions
0 comments No comments
{count} votes

Accepted answer
  1. WhTurner 1,611 Reputation points
    2021-03-05T10:58:08.983+00:00

    Small Basic interprets a WriteLine with spaces and numericals as the printing of a formula "7 + 9" is printed as 16, ignoring the spaces.
    Other non numerical characters (except spaces) force the output to string..
    You can use TextWindow.Write(" "+i+" ") and then TextWindow.Writeline(hold[i])
    or use Textwindow.WriteLine(Text.Append(" "+i+" ",hold[i]))

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.