vb 保存文件对话框

来源:百度知道 编辑:UC知道 时间:2024/05/11 17:20:53
VB6.0 如何保持退出时的状态?

如图:
有控件:Label1、text1、两个按钮
已经设计好的:
Label1.Caption = Text1.Text
按浏览按钮插入图片:
CommonDialog1.Filter = "Jpg图片|*.jpg|Gif图片|*.gif|Bmp图片|*.bmp|"
CommonDialog1.ShowOpen
CommonDialog1.FileName
If CommonDialog1.FileName "" Then
Image1.Picture = LoadPicture(CommonDialog1.FileName)
End If
最后没解决的是:
点保存按钮,便保存当前的label1和插入的图片。程序退出再运行,显示上一次保存的图片和label。
????
该如何写?是不是要用其它控件的?

[img]http://www.vbgood.com/attachments/month_0710/saO05g==_Fmp0hVPOxw9H.jpg[/img]

控件:Label1、1个按钮,CommonDialog1(对话框控件)

Private Sub Command1_Click()
CommonDialog1.Filter = "Jpg图片|*.jpg|Gif图片|*.gif|Bmp图片|*.bmp|"
CommonDialog1.ShowOpen
Label1 = CommonDialog1.FileName
If CommonDialog1.FileName <> "" Then
Image1.Picture = LoadPicture(CommonDialog1.FileName)
End If

End Sub

Private Sub Form_Load()
On Error GoTo errline
Open "temp.txt" For Input As #1
Line Input #1, s
Close #1
Label1 = s
Image1.Picture = LoadPicture(s)
errline:
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Open "temp.txt" For Output As #1
Print #1, Label1
Close #1
End Sub

首先 告诉你再次加载信息会丢失,其它控件也不可能解决,那如何解决呢?
自然让我们联想到*.ini配置文件或*.inf信息文件,
下面我以前写的两个函数 ,记录图片文件夹的位置,通过保存ini文件中来实现系统设置信息,下面列出基本方法,其它使用类似,你自己据一番三吧:

Pri