请问如何用VB新建一个文本文件?
展开全部
sub command1_click()
filename$="c:\" & format(now, "yyyymm") & ".txt"
if len(dir(filename)) then msgbox "文件存在":exit sub
open filename for binary as #1
close #1
end sub
filename$="c:\" & format(now, "yyyymm") & ".txt"
if len(dir(filename)) then msgbox "文件存在":exit sub
open filename for binary as #1
close #1
end sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim nyr As String
On Error GoTo userERR
nyr = Mid(Date$, 1, 4) & Mid(Date$, 6, 2) & Mid(Date$, 9, 2)
Open "c:\" & nyr & ".txt" For Input As #1
Close
MsgBox ("文件存在")
userERR:
Open "c:\" & nyr & ".txt" For Output As #1
Close
End Sub
Dim nyr As String
On Error GoTo userERR
nyr = Mid(Date$, 1, 4) & Mid(Date$, 6, 2) & Mid(Date$, 9, 2)
Open "c:\" & nyr & ".txt" For Input As #1
Close
MsgBox ("文件存在")
userERR:
Open "c:\" & nyr & ".txt" For Output As #1
Close
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim FileNum As Integer
Dim FileName As String
FileNum = FreeFile()
FileName = "c:\" & Format(Now, "YYYYMMDD") & ".txt"
If Dir(FileName) <> "" Then
MsgBox "文件存在"
Else
Open FileName For Output As FileNum
Close FileNum
End If
Dim FileName As String
FileNum = FreeFile()
FileName = "c:\" & Format(Now, "YYYYMMDD") & ".txt"
If Dir(FileName) <> "" Then
MsgBox "文件存在"
Else
Open FileName For Output As FileNum
Close FileNum
End If
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim FileNum As Integer
Dim FileName As String
FileNum = FreeFile()
FileName = "c:\" & datetime.now.todate & ".txt"
If Dir(FileName) <> "" Then
MsgBox "文件存在"
Else
Openfile( filenum,openmode.open)
write(file,"filename.txt","")
Closefile(FileNum)
End If
Dim FileName As String
FileNum = FreeFile()
FileName = "c:\" & datetime.now.todate & ".txt"
If Dir(FileName) <> "" Then
MsgBox "文件存在"
Else
Openfile( filenum,openmode.open)
write(file,"filename.txt","")
Closefile(FileNum)
End If
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |