关于VB保存和打开的问题!

来源:百度知道 编辑:UC知道 时间:2024/06/18 16:01:33
我创建了一个框框。和两个按钮。一个是保存。一个是打开。
我在框框内写入字体后能够保存下来。并能自己命名。下次可以选择打开某个我保存的文件。如何实现.
追加100分。直接给命令就行了,不要解释!

添加一个控件commondialog,自己找吧
textbox 属性设置为带滚动条,允许多行显示的那种!!
以下是简单的例子

打开文件如下:
commondialog1.filter="*.txt"
commondialog1.showopen
If CommonDialog1.FileName = "" Then Exit Sub
fn=freefile()
open commondialog1.filename for input as fn
do while not eof(fn)
line input #fn,s
x=x & s & vbcrlf
loop
close #fn
text1.text=s

以下是保存:
commondialog1.filter="*.txt"
commondialog1.showsave
commondialog1.filterindex=1
If CommonDialog1.FileName = "" Then Exit Sub
fn=freefile()
open commondialog1.filename for output as fn
print #fn,text1.text
close #fn