共用方式為


Small Basic - TextWindow Colors

In Small Basic, you can change the background and foreground colors of the text window's output text using the BackgroundColor and ForegroundColor properties of TextWindow.

You specify the desired color by number or by name. The permissible values are shown here:

Figure: The available TextWindow colors

For example, to output your text in yellow, you can use the word "Yellow" or the number 14:

TextWindow.ForegroundColor = "Yellow"  ' Uses color name

TextWindow.ForegroundColor = 14              ' Uses color number

Have a Small and Basic week!

   - Ninja Ed & Majed Marji

See Also

Comments

  • Anonymous
    March 12, 2016
    You can change the entire TextWindow background colour by doing a Clear after setting the background colour. TextWindow.BackgroundColor = "Red" TextWindow.Clear()

  • Anonymous
    March 13, 2016
    How would i make an orange background ? GraphicsWindow.BackgroundColor="red"+"yellow" would be simple but does not work ? maybe in next version of Small Basic , it would be great to add those simple colors to the basic colors: Orange, Brown, LightGray, MidBlue, MidGreen, MidRed

  • Anonymous
    March 13, 2016
    You can't - the TextWindow is a DOS type Console and the colours are defined by 4 bits (0-15) hence only 16 uique colours. It may be possible  to change the colours assignd to the 16, but not in SB without some extenson to do something like this: stackoverflow.com/.../orange-text-color-in-c-sharp-console-application

  • Anonymous
    March 13, 2016
    here is a way i found for a pseudo orange background, if i set 1 pixels red and the next pixels yellow, and so on we will have the impression of an orange background, it works !! It is an old technical of dot printing graphicsWindow.Clear() ' cls GraphicsWindow.Title = "pseudo orange background" GraphicsWindow.top= 0 GraphicsWindow.left= 0 GraphicsWindow.Height = 768 GraphicsWindow.Width = 1366 While y < 768 For x= 1 To 1366 Step 2  GraphicsWindow.SetPixel(x,y,"red")  GraphicsWindow.SetPixel(x+1,y,"yellow") EndFor y=y+1 EndWhile

  • Anonymous
    March 13, 2016
    That is the GraphicsWindow which we ca set to any colour directly, the 16 colours limit is for the Textindow. GraphicsWindow.BackgroundColor = "Orange" or GraphicsWindow.BackgroundColor = "#FFA500"

  • Anonymous
    March 13, 2016
    That's a great point, LitDev (your first post). Thanks!

  • Anonymous
    December 14, 2016
    lol

  • Anonymous
    November 29, 2017
    The comment has been removed