Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Notepad
- Private Sub menuExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuExit.Click
- Me.Close()
- End Sub
- Private Sub menuOpen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuOpen.Click
- If TextBox1.Modified Then
- Dim ask As MsgBoxResult
- ask = MsgBox("Do you want to save the changes", MsgBoxStyle.YesNoCancel, "Open Document")
- If ask = MsgBoxResult.No Then
- openFD.ShowDialog()
- TextBox1.Text = My.Computer.FileSystem.ReadAllText(openFD.FileName)
- ElseIf ask = MsgBoxResult.Cancel Then
- ElseIf ask = MsgBoxResult.Yes Then
- saveFD.ShowDialog()
- My.Computer.FileSystem.WriteAllText(saveFD.FileName, TextBox1.Text, False)
- TextBox1.Clear()
- End If
- Else
- openFD.ShowDialog()
- TextBox1.Text = My.Computer.FileSystem.ReadAllText(openFD.FileName)
- End If
- End Sub
- Private Sub menuSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuSave.Click
- Dim Save As New SaveFileDialog()
- Dim myStreamWriter As System.IO.StreamWriter
- Save.Filter = "Text [*.txt*]|*.txt|All Files [*.*]|*.*"
- Save.CheckPathExists = True
- Save.Title = "Save File"
- Save.ShowDialog()
- Try
- myStreamWriter = System.IO.File.AppendText(Save.FileName)
- myStreamWriter.Write(TextBox1.Text)
- myStreamWriter.Flush()
- Catch ex As Exception
- End Try
- End Sub
- Private Sub MenuSaveAs_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MenuSaveAs.Click
- saveFD.ShowDialog()
- End Sub
- Private Sub menuCopy_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuCopy.Click
- TextBox1.Copy()
- End Sub
- Private Sub menuPaste_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuPaste.Click
- TextBox1.Paste()
- End Sub
- Private Sub menuCut_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuCut.Click
- TextBox1.Cut()
- End Sub
- Private Sub menuUndo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuUndo.Click
- TextBox1.Undo()
- End Sub
- Private Sub menuNew_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuNew.Click
- Dim value As MsgBoxResult
- value = MsgBox("Do you want to save the changes", MsgBoxStyle.YesNoCancel, "New Document")
- If value = MsgBoxResult.No Then
- TextBox1.Clear()
- ElseIf value = MsgBoxResult.Cancel Then
- ElseIf value = MsgBoxResult.Yes Then
- saveFD.ShowDialog()
- My.Computer.FileSystem.WriteAllText(saveFD.FileName, TextBox1.Text, False)
- TextBox1.Clear()
- End If
- TextBox1.Text = ""
- End Sub
- Private Sub menuSelectAll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuSelectAll.Click
- TextBox1.SelectAll()
- End Sub
- Private Sub menuPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuPrint.Click
- PrintD.ShowDialog()
- End Sub
- Private Sub menuFind_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuFind.Click
- Dim a As String
- Dim b As String
- a = InputBox("What do you want to find")
- b = InStr(TextBox1.Text, a)
- If b Then
- TextBox1.Focus()
- TextBox1.SelectionStart = b - 1
- TextBox1.SelectionLength = Len(a)
- Else
- MsgBox("Text not found.")
- End If
- End Sub
- Private Sub menuFont_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuFont.Click
- fontD.ShowDialog()
- TextBox1.Font = fontD.Font
- End Sub
- Private Sub menuColour_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuColour.Click
- colorD.ShowDialog()
- TextBox1.ForeColor = colorD.Color
- End Sub
- Private Sub menuPageSetup_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuPageSetup.Click
- pageSD.ShowDialog()
- End Sub
- Private Sub menuStatus_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuStatus.CheckedChanged
- If menuStatus.Checked = "true" Then
- SB.Visible = "True"
- Else
- SB.Visible = "False"
- End If
- End Sub
- Private Sub SB_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles SB.MouseHover
- Dim cursorIndex As Integer = TextBox1.SelectionStart
- Dim lineNumber As Integer = TextBox1.GetLineFromCharIndex(cursorIndex)
- Dim characterXY As Point = TextBox1.GetPositionFromCharIndex(cursorIndex)
- Dim characterIndex As Integer = TextBox1.GetCharIndexFromPosition(characterXY)
- SB.Text = lineNumber + 1
- End Sub
- Private Sub SB_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles SB.VisibleChanged
- Dim cursorIndex As Integer = TextBox1.SelectionStart
- Dim lineNumber As Integer = TextBox1.GetLineFromCharIndex(cursorIndex)
- Dim characterXY As Point = TextBox1.GetPositionFromCharIndex(cursorIndex)
- Dim characterIndex As Integer = TextBox1.GetCharIndexFromPosition(characterXY)
- SB.Text = lineNumber + 1
- End Sub
- Private Sub RedoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RedoToolStripMenuItem.Click
- TextBox1.Redo()
- End Sub
- Private Sub menuWordWrap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuWordWrap.Click
- If menuWordWrap.CheckState = "Unchecked" Then
- TextBox1.WordWrap = "false"
- ElseIf menuWordWrap.CheckState = "Checked" Then
- TextBox1.WordWrap = "True"
- End If
- End Sub
- Private Sub menuAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuAbout.Click
- MsgBox("This version of Microsoft Notepad has been created exactly as a clone of MS notepad which you will understand if you aren't too much of a dumbass")
- End Sub
- Private Sub menuHelp_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuHelp.Click
- MsgBox("Since this is a copy of MS notepad, I am sorry to inform you that if you need help, your Intelligence quotient is way too low. Better improve your IQ before coming to use this stuff then")
- End Sub
- Private Sub menuTime_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menuTime.Click
- TextBox1.Text = TextBox1.Text + Now
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement