分类:
2006-01-11 02:24:47
Dim str As String Private Sub Command1_Click() On Error GoTo err cdc.DialogTitle = "选择你要打开的文件" cdc.InitDir = "c:\" cdc.Filter = "*.txt|*.txt" cdc.ShowOpen Open cdc.FileName For Input As #1 If LOF(1) > 0 Then Text1.Text = "" While Not EOF(1) x = DoEvents Line Input #1, str Text1.Text = Text1.Text + str + vbCrLf ' Debug.Print str Wend End If Close #1 Exit Sub err: MsgBox "open file error" Unload Form1 End Sub Private Sub Command2_Click() On Error GoTo err cdc.DialogTitle = "选择你要保存的文件" cdc.InitDir = "c:\" cdc.Filter = "*.txt|*.txt" cdc.ShowSave Open cdc.FileName For Output As #2 Print #2, Text1.Text Close #2 Exit Sub err: MsgBox "open file error" Unload Form1 End Sub |