伟伟VB编程系列┊VB之打开与保存文件

从部件里添加一个CommonDialog控件,写入代码:
CommonDialog1.Filter = "文本文档(*.txt)|*.txt|ASP文件(*.asp)|*.asp|VBS脚本(*.vbs)|*.vbs|所有文件(*.*)|*.*" '显示要保存的所有类型
CommonDialog1.filterindex = 1 '默认保存文件的类型
CommonDialog1.Action = 2 '1为打开,2为保存
Dim str As String
str = CommonDialog1.FileName 'str等于输入保存的文件名
If (Trim(str) <> "") Then
Set fso = CreateObject("scripting.filesystemobject")
Set txt = fso.createtextfile(str)
txt.write (Text1.Text)
MsgBox "文件保存成功!", vbOKOnly + vbInformation, "操作提示"
End If
看看还有没有您感兴趣的:
既然来了,就写两句吧~
是啊,密码不好用哦!没法安装。...