Dim intFileIn As Integer
Dim intFileOut As Integer
Dim strTemp As String
cd.Filter = "XML(*.xml)|*.xml|*.*|*.*"
cd.Flags = &H2&
cd.ShowOpen
intFileIn = FreeFile
intFileOut = FreeFile
If cd.FileName = "" Then
Exit Sub
End If
Open cd.FileName For Input As #intFileIn
strTemp = ""
strTemp = Input$(LOF(1), #intFileIn) '出错语句
Close #intFileIn
Open cd.FileName For Output As #intFileOut
strTemp = Trim(strTemp)
strTemp = Left(strTemp, Len(strTemp) - 9)
strTemp = strTemp & Chr(13) & Chr(10) & strString
Print #intFileOut, strTemp & Chr(13) & Chr(10) & "</sqldef>",
Close #intFileOut
上面的代码只能执行一次,执行第二次时就会出错.请高手们帮忙看看错在什么地方,是不是什么忘记关闭了?
Dim intFileOut As Integer
Dim strTemp As String
cd.Filter = "XML(*.xml)|*.xml|*.*|*.*"
cd.Flags = &H2&
cd.ShowOpen
intFileIn = FreeFile
intFileOut = FreeFile
If cd.FileName = "" Then
Exit Sub
End If
Open cd.FileName For Input As #intFileIn
strTemp = ""
strTemp = Input$(LOF(1), #intFileIn) '出错语句
Close #intFileIn
Open cd.FileName For Output As #intFileOut
strTemp = Trim(strTemp)
strTemp = Left(strTemp, Len(strTemp) - 9)
strTemp = strTemp & Chr(13) & Chr(10) & strString
Print #intFileOut, strTemp & Chr(13) & Chr(10) & "</sqldef>",
Close #intFileOut
上面的代码只能执行一次,执行第二次时就会出错.请高手们帮忙看看错在什么地方,是不是什么忘记关闭了?
strTemp = StrConv(InputB(LOF(1) - 3, #intFileIn), vbUnicode)
请问你为什么这么用呢?这样一来我的文本文件里的内容就会少读入3个字符,去掉减3又说有错误!