Sub Appdoc(ByVal docpath As String, ByVal txt As String)'追加记录函数
Open docpath For Append As #1
Print #1, txt
Close #1
End Sub
Public Function openfile(ByVal filepath As String) As String'读入文件函数
Dim s As String
Open filepath For Input As #1
While Not EOF(1)
Line Input #1, sline
s = s & sline & vbCrLf
Wend
Close #1
openfile = s
End Function
Public Function savefile(ByVal filepath As String, ByVal txt As String)'保存文件函数
Open filepath For Output As #1
Print #1, txt
Close #1
End Function
你用如这样的方法 来区别是追加还是新建保存
If Dir(v3Dpath) <> "" Then
Call Appdoc(v3Dpath, vdays & "$" & vdate & "$" & strNum)
Else
Call savefile(v3Dpath, vdays & "$" & vdate & "$" & strNum)
End If
用VB的OPEN方法,open filename for filemode as #filenum
Open "\你的文件.txt" For Output As #1 '打开文件(如果没有就自动创建)
Print #1'写上内容
Close #1”关闭