我有这个 Private Sub 可以逐行读取文本文件并输出到文本框,我想显示读取的行数,但是当我运行 lbl_LinesRead.Text 时,只有在文件读取完成后才会更新。
我做错了什么?
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles BTN_StartProcess.Click
Dim linesRead As Integer
Dim fileReader As System.IO.StreamReader
Dim stringReader As String
linesRead = 0
fileReader = My.Computer.FileSystem.OpenTextFileReader(fileToRead)
Do
stringReader = fileReader.ReadLine()
TXT_Output.AppendText(stringReader & vbCrLf)
linesRead += 1
lbl_LinesRead.Text = linesRead.ToString
Loop Until stringReader Is Nothing
End Sub
每行读取更新的数字