zoukankan      html  css  js  c++  java
  • [vb.net]控制台进度条的示例

     1  Private Sub ConsoleProcessBar()
     2         Dim isBreak As Boolean = False
     3         Dim colorBack As ConsoleColor = Console.BackgroundColor
     4         Dim colorFore As ConsoleColor = Console.ForegroundColor
     5         '(0,0)(Left,Top) 第一行
     6         Console.WriteLine("***********TE Mason*************")
     7         Console.BackgroundColor = ConsoleColor.DarkCyan
     8         For i = 0 To Console.WindowWidth - 3
     9             '(0,1) 第二行
    10             Console.Write(" ")
    11         Next
    12         '(0,1) 第二行
    13         Console.WriteLine(" ")
    14         Console.BackgroundColor = colorBack
    15         '(0,2) 第三行
    16         Console.WriteLine("0%")
    17         '(0,3) 第四行
    18         Console.WriteLine("<Press Enter To Break>")
    19 
    20         For i = 0 To 100
    21             If Console.KeyAvailable AndAlso Console.ReadKey(True).Key = ConsoleKey.Enter Then
    22                 isBreak = True
    23                 Exit For
    24             End If
    25             Console.BackgroundColor = ConsoleColor.Yellow
    26             '/返回完整的商,包括余数,SetCursorPosition会自动四舍五入
    27             Console.SetCursorPosition(i * (Console.WindowWidth - 2) / 100, 1)
    28             'MsgBox(i * (Console.WindowWidth - 2) / 100)
    29             'MsgBox(Console.CursorLeft)
    30             'MsgBox(Console.CursorSize)
    31             Console.Write(" ")
    32             Console.BackgroundColor = colorBack
    33             Console.ForegroundColor = ConsoleColor.Green
    34             Console.SetCursorPosition(0, 2)
    35             Console.Write("{0}%", i)
    36             Console.ForegroundColor = colorFore
    37             Threading.Thread.Sleep(1000)
    38         Next
    39 
    40         Console.SetCursorPosition(0, 3)
    41         Console.Write(IIf(isBreak, "Break!!!", "Finish"))
    42         Console.WriteLine("                           ")
    43         Console.ReadKey()
    44         Console.ReadKey(True)
    45     End Sub

  • 相关阅读:
    写个简单的搜索引擎
    C++中的三种继承关系
    《深度探索C++对象模型》调用虚函数
    一次数据库优化的对话
    读后感:你的灯亮着吗
    Linux Shell 截取字符串
    一次关于知识储备的思考
    哈夫曼树与哈夫曼编码
    二叉查找树
    jar中没有注清单属性
  • 原文地址:https://www.cnblogs.com/masonlu/p/4668232.html
Copyright © 2011-2022 走看看