框提示"是否继续读取内容",直到全部内容读取完为止。请教vb.net代码。

逐行读取保存在桌面上的文件,并且每读取一行内容都需要信息框提示是否继续读取内容,直到全部内容读取为止。请教vb.net代码

Option Explicit On
Option Strict On

Imports System.IO

Module Program
Sub Main()
' 将f指定为你要读取的文件的路径
Const f As String="t.txt"
Dim line As String=Nothing

Using sr As StreamReader=New StreamReader(f)
Do
line=sr.ReadLine()
If line IsNot Nothing Then
Console.WriteLine(line)
If MsgBoxResult.Yes<>MsgBox("是否继续?", MsgBoxStyle.YesNo) Then
Exit Do
End If
End If
Loop While line IsNot Nothing
End Using
Console.Write("Press any key to continue . . . ")
Console.ReadKey(True)
End Sub
End Module
温馨提示:答案为网友推荐,仅供参考
相似回答