Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有VB.NET控制台应用程序的进度条_Vb.net_Progress Bar_Console Application - Fatal编程技术网

带有VB.NET控制台应用程序的进度条

带有VB.NET控制台应用程序的进度条,vb.net,progress-bar,console-application,Vb.net,Progress Bar,Console Application,我已经编写了一个解析实用程序作为控制台应用程序,并且它工作得非常顺利。该实用工具读取带分隔符的文件,并根据用户值作为命令行参数将记录拆分为两个文件之一(好记录或坏记录) 正在查看进度条或状态指示器,以显示解析时已执行的工作或剩余的工作。我可以很容易地在循环中在屏幕上写一个a,但我想给出一个% 谢谢 1首先,你必须知道你需要多少行。 在循环中计算“intLineCount/100*intCurrentLine” 并使用SetCursor方法在循环中的同一位置打印结果 VB.NET: Dim to

我已经编写了一个解析实用程序作为控制台应用程序,并且它工作得非常顺利。该实用工具读取带分隔符的文件,并根据用户值作为命令行参数将记录拆分为两个文件之一(好记录或坏记录)

正在查看进度条或状态指示器,以显示解析时已执行的工作或剩余的工作。我可以很容易地在循环中在屏幕上写一个a,但我想给出一个%


谢谢

1首先,你必须知道你需要多少行。 在循环中计算“intLineCount/100*intCurrentLine”

并使用SetCursor方法在循环中的同一位置打印结果

VB.NET:

Dim totalLines as Integer = 0
Dim currentLine as integer = 0
For Each line as string in Lines
     ' Your operation

     currentLine += 1I
     Dim Progress as integer = (currentLine / totalLines) * 100

    ' print out the result with the suggested method...
    ' !Caution: if there are many updates consider to update the output only if the value has changed or just every n loop by using the MOD operator or any other useful approach 

Next

1首先,你必须知道你预计会有多少行。 在循环中计算“intLineCount/100*intCurrentLine”

并使用SetCursor方法在循环中的同一位置打印结果

VB.NET:

Dim totalLines as Integer = 0
Dim currentLine as integer = 0
For Each line as string in Lines
     ' Your operation

     currentLine += 1I
     Dim Progress as integer = (currentLine / totalLines) * 100

    ' print out the result with the suggested method...
    ' !Caution: if there are many updates consider to update the output only if the value has changed or just every n loop by using the MOD operator or any other useful approach 

Next

1首先,你必须知道你预计会有多少行。 在循环中计算“intLineCount/100*intCurrentLine”

并使用SetCursor方法在循环中的同一位置打印结果

VB.NET:

Dim totalLines as Integer = 0
Dim currentLine as integer = 0
For Each line as string in Lines
     ' Your operation

     currentLine += 1I
     Dim Progress as integer = (currentLine / totalLines) * 100

    ' print out the result with the suggested method...
    ' !Caution: if there are many updates consider to update the output only if the value has changed or just every n loop by using the MOD operator or any other useful approach 

Next

1首先,你必须知道你预计会有多少行。 在循环中计算“intLineCount/100*intCurrentLine”

并使用SetCursor方法在循环中的同一位置打印结果

VB.NET:

Dim totalLines as Integer = 0
Dim currentLine as integer = 0
For Each line as string in Lines
     ' Your operation

     currentLine += 1I
     Dim Progress as integer = (currentLine / totalLines) * 100

    ' print out the result with the suggested method...
    ' !Caution: if there are many updates consider to update the output only if the value has changed or just every n loop by using the MOD operator or any other useful approach 

Next

最简单的方法是经常更新progressBar变量, 例如:如果您的代码由大约100行组成,或者可能是100个功能
在每个函数或某些代码行使用百分比更新progressbar变量后:)

最简单的方法是经常更新progressbar变量, 例如:如果您的代码由大约100行组成,或者可能是100个功能
在每个函数或某些代码行使用百分比更新progressbar变量后:)

最简单的方法是经常更新progressbar变量, 例如:如果您的代码由大约100行组成,或者可能是100个功能
在每个函数或某些代码行使用百分比更新progressbar变量后:)

最简单的方法是经常更新progressbar变量, 例如:如果您的代码由大约100行组成,或者可能是100个功能
在每个函数或某些代码行之后,使用百分比更新progressbar变量:)

下面是一个如何计算完成百分比并将其输出到进度计数器中的示例:

Option Strict On
Option Explicit On

Imports System.IO

Module Module1
    Sub Main()
        Dim filePath As String = "C:\StackOverflow\tabSeperatedFile.txt"
        Dim FileContents As String()


        Console.WriteLine("Reading file contents")
        Using fleStream As StreamReader = New StreamReader(IO.File.Open(filePath, FileMode.Open, FileAccess.Read))
            FileContents = fleStream.ReadToEnd.Split(CChar(vbTab))
        End Using

        Console.WriteLine("Sorting Entries")
        Dim TotalWork As Decimal = CDec(FileContents.Count)
        Dim currentLine As Decimal = 0D

        For Each entry As String In FileContents
            'Do something with the file contents

            currentLine += 1D
            Dim progress = CDec((currentLine / TotalWork) * 100)

            Console.SetCursorPosition(0I, Console.CursorTop)
            Console.Write(progress.ToString("00.00") & " %")
        Next

        Console.WriteLine()
        Console.WriteLine("Finished.")
        Console.ReadLine()

    End Sub
End Module

以下是如何计算完成百分比并将其输出到进度计数器中的示例:

Option Strict On
Option Explicit On

Imports System.IO

Module Module1
    Sub Main()
        Dim filePath As String = "C:\StackOverflow\tabSeperatedFile.txt"
        Dim FileContents As String()


        Console.WriteLine("Reading file contents")
        Using fleStream As StreamReader = New StreamReader(IO.File.Open(filePath, FileMode.Open, FileAccess.Read))
            FileContents = fleStream.ReadToEnd.Split(CChar(vbTab))
        End Using

        Console.WriteLine("Sorting Entries")
        Dim TotalWork As Decimal = CDec(FileContents.Count)
        Dim currentLine As Decimal = 0D

        For Each entry As String In FileContents
            'Do something with the file contents

            currentLine += 1D
            Dim progress = CDec((currentLine / TotalWork) * 100)

            Console.SetCursorPosition(0I, Console.CursorTop)
            Console.Write(progress.ToString("00.00") & " %")
        Next

        Console.WriteLine()
        Console.WriteLine("Finished.")
        Console.ReadLine()

    End Sub
End Module

以下是如何计算完成百分比并将其输出到进度计数器中的示例:

Option Strict On
Option Explicit On

Imports System.IO

Module Module1
    Sub Main()
        Dim filePath As String = "C:\StackOverflow\tabSeperatedFile.txt"
        Dim FileContents As String()


        Console.WriteLine("Reading file contents")
        Using fleStream As StreamReader = New StreamReader(IO.File.Open(filePath, FileMode.Open, FileAccess.Read))
            FileContents = fleStream.ReadToEnd.Split(CChar(vbTab))
        End Using

        Console.WriteLine("Sorting Entries")
        Dim TotalWork As Decimal = CDec(FileContents.Count)
        Dim currentLine As Decimal = 0D

        For Each entry As String In FileContents
            'Do something with the file contents

            currentLine += 1D
            Dim progress = CDec((currentLine / TotalWork) * 100)

            Console.SetCursorPosition(0I, Console.CursorTop)
            Console.Write(progress.ToString("00.00") & " %")
        Next

        Console.WriteLine()
        Console.WriteLine("Finished.")
        Console.ReadLine()

    End Sub
End Module

以下是如何计算完成百分比并将其输出到进度计数器中的示例:

Option Strict On
Option Explicit On

Imports System.IO

Module Module1
    Sub Main()
        Dim filePath As String = "C:\StackOverflow\tabSeperatedFile.txt"
        Dim FileContents As String()


        Console.WriteLine("Reading file contents")
        Using fleStream As StreamReader = New StreamReader(IO.File.Open(filePath, FileMode.Open, FileAccess.Read))
            FileContents = fleStream.ReadToEnd.Split(CChar(vbTab))
        End Using

        Console.WriteLine("Sorting Entries")
        Dim TotalWork As Decimal = CDec(FileContents.Count)
        Dim currentLine As Decimal = 0D

        For Each entry As String In FileContents
            'Do something with the file contents

            currentLine += 1D
            Dim progress = CDec((currentLine / TotalWork) * 100)

            Console.SetCursorPosition(0I, Console.CursorTop)
            Console.Write(progress.ToString("00.00") & " %")
        Next

        Console.WriteLine()
        Console.WriteLine("Finished.")
        Console.ReadLine()

    End Sub
End Module

%calculation是您的问题还是在同一位置打印它的方式?%calculation是您的问题还是在同一位置打印它的方式?%calculation是您的问题还是在同一位置打印它的方式?我已将您的链接更改为英文因为大多数读者不懂德语,所以我添加了与你的C代码相当的VB.NET版本,因为OP已经标记了这个问题
VB.NET
@BrandonB hi-当然我的错是一个很好的例子!我已经成功地工作了。非常感谢。由于大多数读者不懂德语,我已将您的链接更改为英语版本,并且我添加了与您的C代码相当的VB.NET,因为OP已将此问题标记为
VB.NET
@BrandonB hi-当然,我的错误是一个很好的示例!我已经成功地工作了。非常感谢。由于大多数读者不懂德语,我已将您的链接更改为英语版本,并且我添加了与您的C代码相当的VB.NET,因为OP已将此问题标记为
VB.NET
@BrandonB hi-当然,我的错误是一个很好的示例!我已经成功地工作了。非常感谢。由于大多数读者不懂德语,我已将您的链接更改为英语版本,并且我添加了与您的C代码相当的VB.NET,因为OP已将此问题标记为
VB.NET
@BrandonB hi-当然,我的错误是一个很好的示例!我已经成功地工作了。非常感谢。