问题
单项选择题
使用Do while循环从打开的文件中逐条读取记录。以下能够正确读取数据的程序段是______。
A.Open "c:\Filel.txt" For Input As #1
Do While Not EOF( )
Line Input #1,strLine
Loop
B.Open "c: \File1.txt" For Input As #1
Do While Not EOF(#1)
Line Input #1, strLine
……
Loop
C.FileNo=Freefile
Open FileNo For Input As#1
Do While Not EOF(FileNo)
Line Input #1,strLine
Loop
D.FileNo=FreeFile
Open FileNo For Input As#1
Do While Not EOF(#FileNo)
Line Input#1,strLine
Loop
答案
参考答案:B
解析: 本题的内容是考查如何使用文件号。在选项A中,EOF( )函数中应有文件号;在选项C和D中都有文件号使用时前后不统一的错误,其中选项D中,“#FileNo”的表示形式是错误的。