错误的文件名或号码
以下是源代码:Option Explicit
Sub form_load()
Dim fso
Dim a$, b$, c$
Open App.Path & "\server_path.txt" For Input As #1
Line Input #1, a
Close #1
Open a & "\class.txt" For Input As #1
Line Input #1, b
Do While Not EOF(1)
Line Input #1, c
c = c & vbCrLf
With CobClass
.AddItem c
End With
Loop
Close #1
'复制文件
FileCopy a & "\class.txt", App.Path & "\class.txt"
'复制文件夹
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFolder a & "class", App.Path & "\class", True
MsgBox "载入数据信息完成!", vbOKOnly + vbExclamation, "操作提示"
Me.Show '操作完成显示窗体
End Sub
Sub cobclass_click()
LstFood.Clear
If CobClass.ListIndex = -1 Then
Else
Dim a$, b$
a = CobClass.Text & Label1.Caption
Open App.Path & "\class\" & a For Input As #1 '单击cobobox的项目后,提示错误的文件名或号码,光标停在这里。
Do While Not EOF(1)
Line Input #1, b
b = b & vbCrLf
With LstFood
.AddItem b
End With
Loop
Close #1
End If
End Sub
--------------------编程问答--------------------
Sub form_load()
Dim fso
Dim a$, b$, c$
Open App.Path & "\server_path.txt" For Input As #1
Line Input #1, a
Close #1
Open a & "\class.txt" For Input As #1
Line Input #1, b
Do While Not EOF(1)
c = c & vbCrLf
With CobClass
.AddItem c
End With
Line Input #1, c
Loop
Close #1
'复制文件
FileCopy a & "\class.txt", App.Path & "\class.txt"
'复制文件夹
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFolder a & "\class", App.Path & "\class", True
MsgBox "载入数据信息完成!", vbOKOnly + vbExclamation, "操作提示"
Me.Show '操作完成显示窗体
End Sub
不明白你class.txt里写着什么样的路径.把路径要搞清楚就不会错了. --------------------编程问答--------------------
Option Explicit--------------------编程问答-------------------- 我也想了解,谢谢LZ.
Sub form_load()
Dim fso
Dim a$, b$, c$
Open App.Path & "\server_path.txt" For Input As #1
Line Input #1, a
Close #1
Open a & "\class.txt" For Input As #1
Line Input #1, b
Do While Not EOF(1)
b = b & vbCrLf
With CobClass
.AddItem b
End With
Line Input #1, b
Loop
b = b & vbCrLf
'如果class.txt最后一行没有回车的话,还要加下面一段
With CobClass
.AddItem b
End With
Close #1
'复制文件
FileCopy a & "\class.txt", App.Path & "\class.txt"
'复制文件夹
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFolder a & "\class", App.Path & "\class", True
MsgBox "载入数据信息完成!", vbOKOnly + vbExclamation, "操作提示"
Me.Show '操作完成显示窗体
End Sub
补充:VB , 基础类