private sub command1_click() dim i as integer,s as string open "c:\XXX.LOG" for input as #1 for i=1 to 10 line input #1,s if i>=5 then list1.additem s next i close #1 end sub
完善点的:private sub command1_click() dim i as integer,s as string if dir("c:\XXX.LOG")="" then msgbox "文件不存在" exit sub end if open "c:\XXX.LOG" for input as #1 for i=1 to 10 if eof(1) then msgbox "数据不完整" close #1 exit sub end if line input #1,s if i>=5 then list1.additem s next i close #1 end sub
dim i as integer,s as string
open "c:\XXX.LOG" for input as #1
for i=1 to 10
line input #1,s
if i>=5 then list1.additem s
next i
close #1
end sub
dim i as integer,s as string
if dir("c:\XXX.LOG")="" then
msgbox "文件不存在"
exit sub
end if
open "c:\XXX.LOG" for input as #1
for i=1 to 10
if eof(1) then
msgbox "数据不完整"
close #1
exit sub
end if
line input #1,s
if i>=5 then list1.additem s
next i
close #1
end sub