Dim s As String, fnr As Integer
fnr=freefile
Open "C:\semcitpgrouporiginal\button" & buttonnumber & "list.txt" For Input As #fnr
Do Until EOF(fnr)
Line Input #fnr, s
List1.AddItem s
Loop
Close #fnr
上面是我将文本文件的内容逐行写入数组的程序,
如果我用BOF来判断文本文件内容是否为空时,就会报“函数未定义”的错误。具体程序如下:
dim i as integer
i=0
Open "C:\semcitpgrouporiginal\button" & buttonnumber & "list.txt" For Input As #fnr
do until BOF(fnr)
i=i+1
loop
close #fnr
if i=1 then
text1.text=" there's no item"
end if
没有BOF这个函数。
LOF可以返回一个Open 语句打开的文件的大小,所以可以……
Private Sub Command1_Click()
Dim fnr As Integer
fnr = FreeFile
Open "d:\slorelee\桌面\Test.txt" For Input As #fnr
If LOF(fnr) = 0 Then MsgBox "Empty"
Close #fnr
End Sub
LZ说的是EOF函数吧
Dim InputData
Open "d:\slorelee\桌面\Test.txt" For Input As #1 ' 为输入打开文件。
Do While Not EOF(1) ' 检查文件尾。
Line Input #1, InputData ' 读入一行数据。
If InputData="" Then Msgbox"Noting" ' 判断是否为空
Loop
Close #1 ' 关闭文件。