Set fso = CreateObject("scripting.filesystemobject") If Not fso.FileExists(App.Path & "\list.txt") Then MsgBox("找不到list.txt!") Exit Sub End If Chklist.Clear Set f = fso.OpenTextFile(App.Path & "\list.txt", 1) Do While Not f.AtEndOfStream Chklist.AddItem (f.ReadLine) Loop Set fso = Nothing
Dim Fname As String, Tmp As String If Right(App.Path, 1) <> "\" Then Fname = App.Path & "\list.txt" Else Fname = App.Path & "list.txt" End If If Dir(Fname) <> "" Then Open Fname For Input As #1 Do While Not EOF(1) Line Input #1, Tmp List1.AddItem (Tmp) Loop Close End If
Dim lngFH As Long Dim strTemp As String lngFH = FreeFile '打开文本文件 Open 要打开的文件路径 For Input As lngFH '读取文件并写入list Do While Not EOF(lngFH) Line Input #lngFH, strTemp list1.additem strTemp Loop '关闭文件 Close #lngFH
If Not fso.FileExists(App.Path & "\list.txt") Then
MsgBox("找不到list.txt!")
Exit Sub
End If
Chklist.Clear
Set f = fso.OpenTextFile(App.Path & "\list.txt", 1)
Do While Not f.AtEndOfStream
Chklist.AddItem (f.ReadLine)
Loop
Set fso = Nothing
If Right(App.Path, 1) <> "\" Then
Fname = App.Path & "\list.txt"
Else
Fname = App.Path & "list.txt"
End If
If Dir(Fname) <> "" Then
Open Fname For Input As #1
Do While Not EOF(1)
Line Input #1, Tmp
List1.AddItem (Tmp)
Loop
Close
End If
Dim strTemp As String
lngFH = FreeFile
'打开文本文件
Open 要打开的文件路径 For Input As lngFH
'读取文件并写入list
Do While Not EOF(lngFH)
Line Input #lngFH, strTemp
list1.additem strTemp
Loop
'关闭文件
Close #lngFH