当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET Console.BackgroundColor属性代码示例

本文整理汇总了VB.NET中System.Console.BackgroundColor属性的典型用法代码示例。如果您正苦于以下问题:VB.NET Console.BackgroundColor属性的具体用法?VB.NET Console.BackgroundColor怎么用?VB.NET Console.BackgroundColor使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在System.Console的用法示例。


在下文中一共展示了Console.BackgroundColor属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: Example

Public Module Example
   Public Sub Main()
      ' Get an array with the values of ConsoleColor enumeration members.
      Dim colors() As ConsoleColor = ConsoleColor.GetValues(GetType(ConsoleColor))
      ' Save the current background and foreground colors.
      Dim currentBackground As ConsoleColor = Console.BackgroundColor
      Dim currentForeground As ConsoleColor = Console.ForegroundColor
      
      ' Display all foreground colors except the one that matches the background.
      Console.WriteLine("All the foreground colors except {0}, the background color:",
                        currentBackground)
      For Each color In colors
         If color = currentBackground Then Continue For
          
         Console.ForegroundColor = color
         Console.WriteLine("   The foreground color is {0}.", color)
      Next 
      Console.WriteLine()
      
      ' Restore the foreground color.
      Console.ForegroundColor = currentForeground
      
      ' Display each background color except the one that matches the current foreground color.
      Console.WriteLine("All the background colors except {0}, the foreground color:",
                        currentForeground)
      For Each color In colors
         If color = currentForeground  then Continue For
         Console.BackgroundColor = color
         Console.WriteLine("   The background color is {0}.", color)
      Next
      ' Restore the original console colors.
      Console.ResetColor
      Console.WriteLine()
      Console.WriteLine("Original colors restored...")
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System,代码行数:36,代码来源:Console.BackgroundColor

输出:

The background color is DarkCyan.
The background color is DarkRed.
The background color is DarkMagenta.
The background color is DarkYellow.
The background color is Gray.
The background color is DarkGray.
The background color is Blue.
The background color is Green.
The background color is Cyan.
The background color is Red.
The background color is Magenta.
The background color is Yellow.

Original colors restored...

示例2: Example

Module Example
   Public Sub Main()
      WriteCharacterStrings(1, 26, True)
      Console.MoveBufferArea(0, Console.CursorTop - 10, 30, 1, Console.CursorLeft, Console.CursorTop + 1)
      Console.CursorTop = Console.CursorTop + 3
      Console.WriteLine("Press any key...") : Console.ReadKey()

      Console.Clear()
      WriteCharacterStrings(1, 26, False)
   End Sub
   
   Private Sub WriteCharacterStrings(start As Integer, _end As Integer, 
                                     changeColor As Boolean)
      For ctr As Integer = start To _end
         If changeColor Then
            Console.BackgroundColor = CType((ctr - 1) Mod 16, ConsoleColor)
         End If      
         Console.WriteLine(New String(Convert.ToChar(ctr + 64), 30))
      Next   
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System,代码行数:21,代码来源:Console.BackgroundColor

示例3: Module1

Module Module1

    Sub Main()

        
        Console.Title = "Custom Command Window"
        Console.BackgroundColor = ConsoleColor.White
        Console.ForegroundColor = ConsoleColor.DarkBlue
        Console.WindowHeight = Console.LargestWindowHeight - 15
        Console.WindowWidth = Console.LargestWindowWidth - 15

        'Call a few methods to clear and pause the window.
        Console.Clear()

    End Sub

End Module
开发者ID:VB程序员,项目名称:System,代码行数:17,代码来源:Console.BackgroundColor


注:本文中的System.Console.BackgroundColor属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。