这个是保存的
Private Sub Command78_Click()
Dim i As Integer, j As Integer, n As Integer
Screen.MousePointer = vbHourglass
CommonDialog1.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 If
Open CommonDialog1.FileName For Output As #1
For i = 0 To Form9.List1.ListCount - 1
Print #1, Form9.List1.List(n)
Next
Close #1
End If
Screen.MousePointer = vbDefault
End Sub
这个是导入的
Private Sub Command79_Click()
Dim inputdata As String
Dim File As String
Dim S As String
form9.hide 
CommonDialog1.Filter = "文本文件(*.txt)"
CommonDialog1.Action = 1
File = CommonDialog1.FileName
If File = "" Then
MsgBox "没有选择文件!", vbOKOnly, "文件选择"
Exit Sub
Else
Open CommonDialog1.FileName For Input As #1
Form9.List1.Clear
Do While EOF(1) = False
Line Input #1, S
Form9.List1.AddItem S
Loop
Close #1
End If
End Sub
现在,只是正对于form9的list1,我想加进去form9的list2的和form10的list1,和form11的list1和form12的list1,这两个相对的保存和导入该怎么改

解决方案 »

  1.   

    这个是保存的Private Sub Command78_Click() 
    Dim i As Integer, j As Integer, n As Integer 
    Screen.MousePointer = vbHourglass 
    CommonDialog1.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 If 
    Open CommonDialog1.FileName For Output As #1 
    For i = 0 To Form9.List1.ListCount - 1 
    Print #1, Form9.List1.List(n) 
    Next 
    Close #1 
    End If 
    Screen.MousePointer = vbDefault 
    End Sub 这个是导入的 Private Sub Command79_Click() 
    Dim inputdata As String 
    Dim File As String 
    Dim S As String 
    form9.hide 
    CommonDialog1.Filter = "文本文件(*.txt)" 
    CommonDialog1.Action = 1 
    File = CommonDialog1.FileName 
    If File = "" Then 
    MsgBox "没有选择文件!", vbOKOnly, "文件选择" 
    Exit Sub 
    Else 
    Open CommonDialog1.FileName For Input As #1 
    Form9.List1.Clear 
    Do While EOF(1) = False 
    Line Input #1, S 
    Form9.List1.AddItem S 
    Loop 
    Close #1 
    End If 
    End Sub 现在,只是正对于form9的list1,我想加进去form9的list2的和form10的list1,和form11的list1和form12的list1,这两个相对的保存和导入该怎么改
      

  2.   

    恩,有进步。你进一步把代码像下面这样缩进好,就会有人来帮你了:)
    Private Sub Command78_Click()
        Dim i As Integer, j As Integer, n As Integer
        
        Screen.MousePointer = vbHourglass
        CommonDialog1.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 If
            Open CommonDialog1.FileName For Output As #1
            For i = 0 To Form9.list1.ListCount - 1
                Print #1, Form9.list1.List(n)
            Next
            Close #1
        End If
        Screen.MousePointer = vbDefault
    End Sub