Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Private Sub Form_Load()
- mnuClose.Enabled = False
- End Sub
- Private Sub mnuClose_Click()
- txtFile.Text = "" 'clear text box
- lblFile.Caption = "Load a text file with the Open command."
- mnuClose.Enabled = False 'dim Close command
- mnuOpen.Enabled = True 'enable Open command
- txtFile.Enabled = False 'disable text box
- End Sub
- Private Sub mnuExit_Click()
- End
- End Sub
- Private Sub mnuOpen_Click()
- Wrap$ = Chr$(13) + Chr$(10) 'create wrap character
- CommonDialog1.Filter = "Text files (*.TXT)|*.TXT"
- CommonDialog1.ShowOpen 'display Open dialog box
- If CommonDialog1.FileName <> "" Then
- Form1.MousePointer = 11 'display hourglass
- Open CommonDialog1.FileName For Input As #1
- On Error GoTo TooBig: 'set error handler
- Do Until EOF(1) 'then read lines from file
- Line Input #1, LineOfText$
- AllText$ = AllText$ & LineOfText$ & Wrap$
- Loop
- lblFile.Caption = CommonDialog1.FileName
- txtFile.Text = AllText$ 'display file
- txtFile.Enabled = True
- mnuClose.Enabled = True
- mnuOpen.Enabled = False
- CleanUp:
- Form1.MousePointer = 0 'reset mouse
- Close #1 'close file
- End If
- Exit Sub
- TooBig: 'error handler displays message
- MsgBox ("The specified file is to big")
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment