Вот код:
- Код: Выделить всё
Dim sFile As String
With dlgCommonDialog
.DialogTitle = "Open"
.CancelError = False
.Filter = "x Files (*.x)|*.x"
.ShowOpen
End With
Dim A As String
Open dlgCommonDialog.FileName For Input As #1
Input #1, A
txt1.Text = A
Close #1
Sub SaveAs()
On Error GoTo Err0
With frmMain
.dlgCommonDialog.CancelError = True
.dlgCommonDialog.DialogTitle = "Save File As..."
.dlgCommonDialog.FileName = CurrentFile
If CurrentFile = "" Then CurrentFile = "Untitled.x"
.dlgCommonDialog.Filter = "x Files (*.x)|*.x|All Files (*.*)|*.*"
.dlgCommonDialog.ShowSave
.dlgCommonDialog.Flags = 4
CurrentFile = .dlgCommonDialog.FileName
If Dir$(CurrentFile) <> "" Then
k = MsgBox("The File" & Cr & CurrentFile & Cr & "Already exists. Are you sure you wish to replace it?", 35, "Replcace File?")
Select Case k
Case vbYes
Case vbNo
Call SaveAs
Exit Sub
Case vbCancel
Exit Sub
End Select
End If
End With
CHANGED = False
Call forSaveas
Call EndForm
Exit Sub
Err0:
End Sub
Sub forSaveas()
On Error GoTo errorhandling
Dim A As String
Open frmMain.dlgCommonDialog.FileName For Output As #A
Print #A, frmMain.txt1.Text
Close #A
CHANGED = False
Call EndForm
Exit Sub
errorhandling:
MsgBox "An error occurred while attempting to save " & Cr & FileX & "." & Cr & "Cannot write file.", 16, "Programm - Error!": Exit Sub
End Sub
Он должен сохр. текст из txt1.Text ! И загружать текст в txt1.Text
Изначально в txt1.Text есть текст "Hi all"!
Так он сохраняет строки Hi all и их загружает! Если в txt1.Text Изначально пусто(сразу как загр. форма) то он так и сохр. НЕЗАВИСЕМО КАКОИ ТЕКСТ ВВЕЛ ПОЛЬЗ.
Help!
