请问使用CommonDialog控件如何保存文件,现在只能选已存在的文件覆盖.
请问使用CommonDialog控件如何保存文件,现在只能选已存在的文件覆盖.无法我输入一个文件名保存为一个新的文件。Private Sub Command3_Click()
CommonDialog1.FileName = ""
CommonDialog1.Filter = "数据文件(*.dat)"
CommonDialog1.DialogTitle = "保存文件"
CommonDialog1.InitDir = App.Path & "\"
CommonDialog1.ShowSave
CommonDialog1.Flags = cdlOFNOverwritePrompt
If CommonDialog1.FileName <> "" And Dir(CommonDialog1.FileName) <> "" Then
fliename = CommonDialog1.FileName
strText = Text1.Text
Open fliename For Output As #2
Print #2, strText
Close #2
End If
End Sub --------------------编程问答-------------------- 如果要新建保存文件的话,要使用FileSystemObject,创建文件。 --------------------编程问答-------------------- Private Sub Command3_Click()
CommonDialog1.FileName = ""
CommonDialog1.Filter = "数据文件(*.dat)"
CommonDialog1.DialogTitle = "保存文件"
CommonDialog1.InitDir = App.Path & "\"
CommonDialog1.Flags = cdlOFNOverwritePrompt
CommonDialog1.ShowSave
If CommonDialog1.FileName <> "" Then
fliename = CommonDialog1.FileName
strText = Text1.Text
Open fliename For Output As #2
Print #2, strText
Close #2
End If
End Sub
补充:VB , 控件