vb保存文件的问题

我想按下按钮后出现一个保存对话框,把text1里的文字保存成一个txt文件,请问各位我该怎么办。

楼上的对了,只不过太粗糙,如果楼主是个新手肯定不明白,我补充一下
“工具”-->“引用”,在打开的对话框中选择“windows common control dialog ”(怎么写的我忘了,不太精确)-->“确定”
你一定有“保存”按钮吧,双击,它输入
cmd1.filter=“文本文件(*.txt)|*.txt”
cmd1.ShowSave
If Not Len(cmd1.FileName) = 0 Then
Open cmd1.FileName For Output As #1
Print #1, Text1
Close #1
End If
温馨提示:答案为网友推荐,仅供参考
第1个回答  2006-12-24
Private Sub Command1_Click()
cmd1.ShowSave 'cmd1是一个commondialog控件
If Not Len(cmd1.FileName) = 0 Then
Open cmd1.FileName For Output As 1 '打开一个你刚才输入的文件名,作为输出。
Print #1, Text1.Text '写数据
Close 1 '关闭
End If

End Sub
第2个回答  2019-06-10
哈哈,简单
CommonDialog1.Filter
=
"文本文档(*.txt)|*.txt|RTF文档(*.rtf)|*.rtf|所有文件(*.*)|*.*"
'CommonDialog1.ShowSave
FileType
=
CommonDialog1.FileTitle
FiType
=
LCase(Right(FileType,
3))
FileName
=
CommonDialog1.FileName
Select
Case
FiType
Case
"txt"
ActiveForm.RichTextBox1.SaveFile
FileName,
rtfText
Case
"rtf"
ActiveForm.RichTextBox1.SaveFile
FileName,
rtfRTF
Case
"*.*"
ActiveForm.RichTextBox1.SaveFile
FileName
End
Select
就是不显示
CommonDialog1.ShowSave
就可以了
第3个回答  2019-01-17
在窗体上画两个Text控件,Text1用来防止路径:Text2用来存储读出来的变量。
dim
Str
as
string
'打开
open
Text1.text
for
input
as
#1
do
while
not
(1)
line
input
#1,Str
Str=Str
&
Str
&
vbcrlf
loop
close
#1
text2.text=str
'保存
open
Text1.text
for
output
as
#2
print
#2,text2.text
close
#2
参考一下,看是否合你意.