Text Editor in VB 03-23-2014, 02:17 PM
#1
Well recently I made a text editor in VB, I learn better when I know what I'm working towards, so I found some tuts around the web and combined them with what I was learning in my VB tutorial course to create a text editor that works like notepad and allows you to change the background, text color, etc. For some reason it crashes when you try to change the font though, no idea why.
Preview:
![[Image: Acp4wm8.png]](http://i.imgur.com/Acp4wm8.png)
Code:
Download Link:
https://mega.co.nz/#!6IoUDYaR!H8p8ybRVwv...pA8iZ2_TYk
Virustotal Scan:
https://www.virustotal.com/en/file/95f87...395580547/
Also ignore the name, I know it's called CreatingMenu's, but that's because it was at first me just working on creating menu's since I was at that bit in my tutorials, but as previously mentioned, I work better when working towards something, so I ended up combining it with other tut's and making a text editor.
Preview:
![[Image: Acp4wm8.png]](http://i.imgur.com/Acp4wm8.png)
Code:
Code:
Public Class textEditor
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
'Exits the program
Me.Close()
End Sub
Private Sub SoftwareVersionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SoftwareVersionToolStripMenuItem.Click
'Displays a messagebox informing the user of their software version
MessageBox.Show("You are using version 1.0", "Software Version")
End Sub
Private Sub DeveloperInfoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeveloperInfoToolStripMenuItem.Click
'Displays a messagebox with developer information
MessageBox.Show("This version of this software was created by Thomas Ballard in 2014.", "Developer Info.")
End Sub
Private Sub FontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontToolStripMenuItem.Click
Dim Font As New FontDialog()
Font.Font = txtEditor.Font
Font.ShowDialog(Me)
Try
txtEditor.Font = Font.Font
Catch ex As Exception
' Do nothing on Exception
End Try
End Sub
Private Sub ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem1.Click
Dim Response As MsgBoxResult
Response = MsgBox("Are you sure you want to start a New Document?", _
MsgBoxStyle.Question + MsgBoxStyle.YesNo, _
"Text Editor")
If Response = MsgBoxResult.Yes Then
txtEditor.Text = ""
Me.Text = "Text Editor - Untitled"
End If
End Sub
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
Dim Open As New OpenFileDialog()
Dim myStreamReader As System.IO.StreamReader
Open.Filter = "Plain Text Files (*.txt)|*.txt|All files (*.*)|*.*"
Open.CheckFileExists = True
Open.ShowDialog(Me)
Try
Open.OpenFile()
myStreamReader = System.IO.File.OpenText(Open.FileName)
txtEditor.Text = myStreamReader.ReadToEnd()
Me.Text = "Text Editor - " & Open.FileName
Catch ex As Exception
' Do nothing on Exception
End Try
End Sub
Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
Dim Save As New SaveFileDialog()
Dim myStreamWriter As System.IO.StreamWriter
Save.Filter = "Plain Text Files (*.txt)|*.txt|All files (*.*)|*.*"
Save.CheckPathExists = True
Save.ShowDialog(Me)
Try
myStreamWriter = System.IO.File.CreateText(Save.FileName)
myStreamWriter.Write(txtEditor.Text)
myStreamWriter.Flush()
Me.Text = "Text Editor - " & Save.FileName
Catch ex As Exception
' Do nothing on Exception
End Try
End Sub
Private Sub MenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClicked
End Sub
Private Sub MenuStrip2_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles MenuStrip2.ItemClicked
End Sub
Private Sub ShowTextEditorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
'Hides the text editor
End Sub
Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripMenuItem.Click
txtEditor.Cut()
End Sub
Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click
txtEditor.Copy()
End Sub
Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click
txtEditor.Paste()
End Sub
Private Sub DeleteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteToolStripMenuItem.Click
txtEditor.SelectedText = ""
End Sub
Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllToolStripMenuItem.Click
txtEditor.SelectAll()
End Sub
Private Sub TimeDateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimeDateToolStripMenuItem.Click
txtEditor.SelectedText = Format(Now, "HH:mm dd/MM/yyyy")
End Sub
Private Sub ColourToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColourToolStripMenuItem.Click
Dim Colour As New ColorDialog()
Colour.Color = txtEditor.ForeColor
Colour.ShowDialog(Me)
Try
txtEditor.ForeColor = Colour.Color
Catch ex As Exception
' Do nothing on Exception
End Try
End Sub
Private Sub BackgroundToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackgroundToolStripMenuItem.Click
Dim Colour As New ColorDialog()
Colour.Color = txtEditor.BackColor
Colour.ShowDialog(Me)
Try
txtEditor.BackColor = Colour.Color
Catch ex As Exception
' Do nothing on Exception
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtEditor.Text = ""
Me.Text = "Text Editor - Untitled"
MaximizeBox = False
End Sub
Private Sub ExitTheProgramToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitTheProgramToolStripMenuItem.Click
Me.Close()
End Sub
End Class
Download Link:
https://mega.co.nz/#!6IoUDYaR!H8p8ybRVwv...pA8iZ2_TYk
Virustotal Scan:
https://www.virustotal.com/en/file/95f87...395580547/
Also ignore the name, I know it's called CreatingMenu's, but that's because it was at first me just working on creating menu's since I was at that bit in my tutorials, but as previously mentioned, I work better when working towards something, so I ended up combining it with other tut's and making a text editor.
Proud Member of the BPSG.
![[Image: 5qK1iJK.png]](http://i.imgur.com/5qK1iJK.png)
I couldn't bring myself to remove the hood classic above, enjoy it as a time capsule.