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