SaNeLSANY

Forma

Apr 8th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. Option Explicit
  2.  
  3. Private Sub Form_Load()
  4. mnuClose.Enabled = False
  5. End Sub
  6.  
  7. Private Sub mnuClose_Click()
  8. txtFile.Text = "" 'clear text box
  9. lblFile.Caption = "Load a text file with the Open command."
  10. mnuClose.Enabled = False 'dim Close command
  11. mnuOpen.Enabled = True 'enable Open command
  12. txtFile.Enabled = False 'disable text box
  13. End Sub
  14.  
  15. Private Sub mnuExit_Click()
  16. End
  17. End Sub
  18.  
  19. Private Sub mnuOpen_Click()
  20. Wrap$ = Chr$(13) + Chr$(10) 'create wrap character
  21. CommonDialog1.Filter = "Text files (*.TXT)|*.TXT"
  22. CommonDialog1.ShowOpen 'display Open dialog box
  23. If CommonDialog1.FileName <> "" Then
  24. Form1.MousePointer = 11 'display hourglass
  25. Open CommonDialog1.FileName For Input As #1
  26. On Error GoTo TooBig: 'set error handler
  27. Do Until EOF(1) 'then read lines from file
  28. Line Input #1, LineOfText$
  29. AllText$ = AllText$ & LineOfText$ & Wrap$
  30. Loop
  31. lblFile.Caption = CommonDialog1.FileName
  32. txtFile.Text = AllText$ 'display file
  33. txtFile.Enabled = True
  34. mnuClose.Enabled = True
  35. mnuOpen.Enabled = False
  36. CleanUp:
  37. Form1.MousePointer = 0 'reset mouse
  38. Close #1 'close file
  39. End If
  40. Exit Sub
  41. TooBig: 'error handler displays message
  42. MsgBox ("The specified file is to big")
  43. End Sub
Advertisement
Add Comment
Please, Sign In to add comment