vb在指定程序保存的目录下创建指定名称的txt并将#1文件内容写入这个txt并保存在这个文件夹中

最好用上filelistbox!
2025-02-24 12:07:32
推荐回答(1个)
回答1:

Dim strPath$, strFileName$, strTmp$, iSeq%
strPath = App.Path & "\" '当前目录
strTmp = Text1.Text '文件名称
strFileName = strPath & strTmp & ".Txt" '假设文件类型为TXT文本文件
iSeq = 0 '文件序号
Do While Dir(strFileName) <> ""
iSeq = iSeq + 1
strTmp = Text1.Text & CStr(iSeq)
strFileName = strPath & strTmp & ".Txt" '假设文件类型为TXT文本文件
Loop

Dim iFn%
iFn = FreeFile
Open strFileName For Output As iFn
Print #iFn, Text1.Text & CStr(iSeq) '写入文件内容
Close #iFn