1. 输出文件函数
Function GenFile(ByVal File As String, ByVal text As String)
Open File For Output As #1
Print #1, text
Close #1
End Function
2. 使用方法
运行下面的代码后会在桌面输出test.txt文件。
Sub GenFileTest()
Dim strFile As String
Dim strContext As String
strFile = Environ("USERPROFILE") & Application.PathSeparator & "Desktop" & Application.PathSeparator & "test.txt"
strContext = "测试文本"
Call GenFile(strFile, strContext)
End Sub
3. 其他
如果要输出UTF-8格式文件请参照