还有我下面函数读文件怎么s是空值呢,我的文件里是有值的
Private Function ReadFile(j As Long) As String
Dim s As String
Dim i As Long
Dim FolderPath As String
Dim FileName As String
FolderPath = app.Path & "\"
FileName = "SystemConfig.txt"
FileName = FolderPath & FileName
Open FileName For Input As #1
i = 0
Do Until EOF(1)
i = i + 1
Line Input #1, s
If i = j Then '读第j行
Print s
Exit Do '避免浪费
End If
Loop
Close #1
MsgBox (s)
ReadFile = s
End Function
Private Function ReadFile(j As Long) As String
Dim s As String
Dim i As Long
Dim FolderPath As String
Dim FileName As String
FolderPath = app.Path & "\"
FileName = "SystemConfig.txt"
FileName = FolderPath & FileName
Open FileName For Input As #1
i = 0
Do Until EOF(1)
i = i + 1
Line Input #1, s
If i = j Then '读第j行
Print s
Exit Do '避免浪费
End If
Loop
Close #1
MsgBox (s)
ReadFile = s
End Function
Mode:
Append:如果文件存在,程序要在文件尾些数据,如果不存在,创建文件
Input:程序要从文件中读取数据
output:程序要在文件中写数据,如果文件不存在,创建文件;如果存在,先删除文件再建立同名文件。
用顺序文件纯粹找死
速度慢不说,处理出来非常麻烦用二进制方式打开
全部读取到一String
对那个String进行操作
再写入文件
dim qq as string
Open strfilename For Binary As #1
qq = Input(LOF(1), 1)
Text1.Text = qq
我也只知道这里了
因为它的单位是UniCode字符
而LOF返回的是字节读取:
Dim TempFile As Long
Dim LoadBytes() As ByteTempFile=FreeFile
Open 文件名 For Binary As #TempFile
Redim LoadBytes(1 To Lof(TempFile)) As Byte
Get #TempFile,,LoadBytes
Close TempFileText1.Text=StrConv(LoadBytes,vbUniCode)