home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
- Begin VB.Form TextFileForm
- Caption = "Text File I/O Demo"
- ClientHeight = 5190
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 7320
- LinkTopic = "Form1"
- ScaleHeight = 5190
- ScaleWidth = 7320
- StartUpPosition = 3 'Windows Default
- Begin MSComDlg.CommonDialog CommonDialog1
- Left = 30
- Top = 4470
- _ExtentX = 847
- _ExtentY = 847
- _Version = 393216
- End
- Begin VB.CommandButton bttnExit
- Caption = "E X I T"
- Height = 525
- Left = 5640
- TabIndex = 4
- Top = 4560
- Width = 1515
- End
- Begin VB.CommandButton bttnFileSaveAs
- Caption = "Save File As"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 525
- Left = 3495
- TabIndex = 3
- Top = 4575
- Width = 1515
- End
- Begin VB.CommandButton bttnFileSave
- Caption = "Save File"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 525
- Left = 1830
- TabIndex = 2
- Top = 4575
- Width = 1515
- End
- Begin VB.CommandButton bttnFileOpen
- Caption = "Open File"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 525
- Left = 135
- TabIndex = 1
- Top = 4575
- Width = 1515
- End
- Begin VB.TextBox Text1
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 4305
- Left = 105
- MultiLine = -1 'True
- ScrollBars = 2 'Vertical
- TabIndex = 0
- Top = 120
- Width = 7065
- End
- Attribute VB_Name = "TextFileForm"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Dim OpenFile As String
- Private Sub bttnExit_Click()
- End
- End Sub
- Private Sub bttnFileOpen_Click()
- Dim FNum As Integer
- Dim txt As String
- On Error GoTo FileError
- CommonDialog1.CancelError = True
- CommonDialog1.Flags = cdlOFNFileMustExist
- CommonDialog1.DefaultExt = "TXT"
- CommonDialog1.Filter = "Text files|*.TXT|All files|*.*"
- CommonDialog1.ShowOpen
- FNum = FreeFile
- Open CommonDialog1.FileName For Input As #1
- txt = Input(LOF(FNum), #FNum)
- Close #FNum
- Text1.Text = txt
- OpenFile = CommonDialog1.FileName
- Exit Sub
- FileError:
- If Err.Number = cdlCancel Then Exit Sub
- MsgBox "Unkown error while opening file " & CommonDialog1.FileName
- OpenFile = ""
- End Sub
- Private Sub bttnFileSave_Click()
- Dim FNum As Integer
- Dim txt As String
- If OpenFile = "" Then
- bttnFileSaveAs_Click
- Exit Sub
- End If
- On Error GoTo FileError
- FNum = FreeFile
- Open OpenFile For Output As #1
- Print #FNum, Text1.Text
- Close #FNum
- Exit Sub
- FileError:
- If Err.Number = cdlCancel Then Exit Sub
- MsgBox "Unkown error while saving file " & OpenFile
- OpenFile = ""
- End Sub
- Private Sub bttnFileSaveAs_Click()
- Dim FNum As Integer
- Dim txt As String
- On Error GoTo FileError
- CommonDialog1.CancelError = True
- CommonDialog1.Flags = cdlOFNOverwritePrompt
- CommonDialog1.DefaultExt = "TXT"
- CommonDialog1.Filter = "Text files|*.TXT|All files|*.*"
- CommonDialog1.ShowSave
- FNum = FreeFile
- Open CommonDialog1.FileName For Output As #1
- Print #FNum, Text1.Text
- Close #FNum
- OpenFile = CommonDialog1.FileName
- Exit Sub
- FileError:
- If Err.Number = cdlCancel Then Exit Sub
- MsgBox "Unkown error while saving file " & CommonDialog1.FileName
- OpenFile = ""
- End Sub
-