ConsoleColor()

语法

ConsoleColor(CharacterColor, BackgroundColor)
概要
更改用来显示文本的颜色。调用此函数后控制台上打印的所有字符都将使用您新指定的颜色。

参数

CharacterColor 此颜色用于字符。颜色范围在0-15,控制台模式下只有16种颜色有效::
  0 - Black (default background)
  1 - 蓝色
  2 - 绿色
  3 - Cyan
  4 - 红色
  5 - Magenta
  6 - Brown
  7 - Light grey (default foreground)
  8 - Dark grey
  9 - Bright blue
  10 - Bright green
  11 - Bright cyan
  12 - Bright red
  13 - Bright magenta
  14 - 黄色
  15 - 白色
BackgroundColor The color for the character background. The values are the same as for the CharacterColor.

返回值

无.

示例

  If OpenConsole()
    For Foreground = 0 To 15
      For Background = 0 To 15
        ConsoleColor(Foreground, Background)
        Print(Right(Hex(Background), 1))
      Next
        
      PrintN("")
    Next
    
    ConsoleColor(7, 0)
    PrintN("Press return to exit")
    Input()
  EndIf

参阅

EnableGraphicalConsole()

已支持操作系统

Windows

<- CloseConsole() - Console 索引 - ConsoleCursor() ->