JayBeeOH

TxtEditor - File New Option.

Feb 18th, 2015
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.72 KB | None | 0 0
  1. '------------------------------------------------------------------------------------------
  2. '           Notice of My Copyright and Intellectual Property Rights
  3. '
  4. ' Any intellectual property contained within the program by Joseph L. Bolen remains the
  5. ' intellectual property of the Joseph L. Bolen. This means that no person may distribute,
  6. ' publish or provide such intellectual property to any other person or entity for any
  7. ' reason, commercial or otherwise, without the express written permission of Joseph L.
  8. ' Bolen.
  9. '
  10. '                 Copyright © 2015. All rights reserved.
  11. '        All trademarks remain the property of their respective owners.
  12. '-------------------------------------------------------------------------------------------
  13. ' Program Name:   Text Editor
  14. '
  15. ' Author:         Joseph L. Bolen
  16. ' Date Created:   Feb 2015
  17. '
  18. ' Description:    Simple plain text editor program with printing ability.
  19. '
  20. '                 Documentation is at:
  21. '                   App's screen image is at: http://imgur.com/TzWs9kO
  22. '                   App's screen design time specs at: http://pastebin.com/bhinRQ5d
  23. '                   App's Visual Basic .NET Event Procedures & TODO's is at
  24. '                       http://pastebin.com/UZ4tcEpE
  25. '                   App's Visual Basic .NET code is at http://pastebin.com/u/jaybeeoh
  26. '                   Video tutorial at YouTube: http://www.youtube.com/user/bolenpresents
  27. '-------------------------------------------------------------------------------------------
  28.  
  29. #Region "  Declare class level variables"
  30.  
  31.     Public applicationTitle As String = My.Application.Info.Title
  32.     Private workingPathFile As String = String.Empty
  33.    
  34. #End Region  
  35.  
  36.     ' File New option.
  37.     Private Sub NewToolStripMenuItem_Click(sender As Object, e As EventArgs) _
  38.         Handles NewToolStripMenuItem.Click, NewToolStripButton.Click
  39.  
  40.         If SaveChanges() Then
  41.             SaveToolStripMenuItem_Click(sender, e)
  42.         End If
  43.  
  44.         workingPathFile = String.Empty
  45.         Me.Text = applicationTitle
  46.  
  47.         With MyTextBox
  48.             .Clear()
  49.             .Modified = False
  50.             .Focus()
  51.         End With
  52.     End Sub
  53.  
  54.     ' If MyTextBox has been modifed, check to see if changes should be saved.
  55.     Private Function SaveChanges() As Boolean
  56.  
  57.         If (MyTextBox.Modified) AndAlso (Not String.IsNullOrWhiteSpace(MyTextBox.Text)) Then
  58.             If MsgBoxResult.Yes = MessageBox.Show("Do you want to save your changes?",
  59.                             "Save Changes",
  60.                             MessageBoxButtons.YesNo,
  61.                             MessageBoxIcon.Question) Then
  62.                 Return True
  63.             End If
  64.         End If
  65.         Return False
  66.     End Function
Advertisement
Add Comment
Please, Sign In to add comment