现在在1窗体1有
Command1,和Command2
现在想点击Command1,保存每个窗体所有数据到本文件夹内,届时我可以自己给这个保存文件取个名字,然后将来我要用到的时候,我点击Command2可以选择在把它调出来
如我现在点击Command1,就像
Private Sub Command11_Click()
Dim i As Integer, j As Integer, n As IntegerScreen.MousePointer = vbHourglassCommonDialog1.Filter = "文本文件(*.txt)"
CommonDialog1.ShowSave
If CommonDialog1.FileName <> "" Then
If Dir(CommonDialog1.FileName) <> vbNullString Then
If MsgBox("原文件存在,是否覆盖?", vbYesNo, "提示框") = vbYes Then
Kill CommonDialog1.FileName
Else
Exit Sub
End If
End IfOpen CommonDialog1.FileName For Output As #1
For i = 0 To List2.ListCount - 1
Print #1, List2.List(n)
Next
Close #1
End If
Screen.MousePointer = vbDefault
End Sub
这样弹出对话框,然后我可以自己命名保存文件,但这个只是针对与List2,我要的是保存所有窗体数据
将来我需要这个数据时我点击Command2,然后向
Private Sub Command12_Click()
Dim inputdata As String
Dim File As StringDim S As String
CommonDialog1.Filter = "文本文件(*.txt)"
CommonDialog1.Action = 1
File = CommonDialog1.FileName
If File = "" Then
MsgBox "没有选择文件!", vbOKOnly, "文件选择"Exit Sub
ElseOpen CommonDialog1.FileName For Input As #1
List2.Clear
Do While EOF(1) = False
Line Input #1, S
List2.AddItem S
Loop
Close #1
End If
List2.ListIndex = List2.ListCount - 1
End Sub
这个一样,我可以选择导入那个文件,然后导入,这时每个窗体的数据各自归位,就像我当初保存他是一样,这个该怎么写