计算机vb二级考试疑问,请高手指点

来源:百度知道 编辑:UC知道 时间:2024/05/25 04:00:22
在程序编写中,需要读入 “in5.txt”文件中的内容。答案编写为:
Open App.Path & "in5.tex" For Input As #1
为什么在调试时,显示:错误53 文件未找到 (在电脑中有这个文件)
你好意思 打错了 是\in5.txt
和工程文件是在同以文件夹

in5.txt需要和工程文件在同一个文件夹中才可以使用App.path

Open App.Path & "in5.tex" For Input As #1
中间错了两个字母,应该是
Open App.Path & "\in5.txt" For Input As #1
注意,如果程序不在根目录下时,一定要加个 斜杠

少个“\”,改成 下面:

Open App.Path & "\in5.tex" For Input As #1

或改成下面:

open iif(right(app.path,1)="\",app.path,app.path & "\") & "in5.txt" for input as #1

Public Function Get_INI_String(ByVal Section As String, ByVal Key As String, ByVal Default As String, ByVal INI_FileName As String) As String
Dim X As Integer
Const BufferSize = 256
Dim tmp As String * BufferSize

Section = Section + Chr$(0)
Key = Key + Chr$(0)
INI_FileName = INI_FileName + Chr$(0)

X = GetPrivateProfileString(Section, Key, Default, tmp, BufferSize, INI_FileName)
Get_INI_String = Left$(tmp, X)
End Function
主程序调用时候
dim temp1,temp2