VB保存文件

来源:百度知道 编辑:UC知道 时间:2024/06/01 19:48:46
是这样的
有一个TEXT1的文本(里面的内容是前边计算生成的)
然后有个按钮,这个按钮要实现把TEXT1的内容保存,就是出现个保存路径的对话框
怎么写呀?急~~~~~~~~明天交报告了,谢谢

引用microsoft common dialog control 6.0

Private Sub BtnExl_Click()
'调用文件选择框
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
CommonDialog1.Filter = "Microsoft Excel(*.txt) | *.txt"
CommonDialog1.FileName = “要保存的文件名"
CommonDialog1.ShowSave
Call Cell1.DoExportExcelFile(CommonDialog1.FileName)
MsgBox "保存成功!", 64, "成功!"
Exit Sub
ErrHandler:
Exit Sub
End Sub

使用部件里的“microsoft common dialog 6.0”,然后使用下列代码

Commondialog1.action=1
open Commondialog1.filename for output as #1
print #1,text1.text
close #1
end

楼上的比我的好,别用我的了