2 Replies - 1652 Views - Last Post: 16 March 2011 - 02:54 PM Rate Topic: -----

#1 hifistyle  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 11-October 10

adding cut, copy, and paste functionality to a word processor form VB

Posted 16 March 2011 - 01:21 PM

I need to add cut, copy, and paste functionality to my word processor.
I'm using Visual Studio 2010 and we have no textbook this semester.
I know they're in that tool box somewhere!

Thanks for any advice!
John

Public Class wordProcessorForm

    Dim mblnDirty As Boolean

    Private Sub wordProcessorForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub NewToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
        Dim pintdialogresult As DialogResult
        If mblnDirty Then
            MessageBox.Show("Abandon Changes?", "Confirm", MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question)

            If pintdialogresult = DialogResult.No Then
                Exit Sub
            End If
        End If

        rtbdocument.Text = ""

        wordProcessorForm.ActiveForm.Text = "New Document"

        mblnDirty = False


    End Sub

    Private Sub OpenToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
        On Error Resume Next
        With ofdFile

            .Title = "Select a file to open"
            .Filter = "Show All Files (*.txt) | *.txt" & _
            "|HTML Files (*.htm)|*.htm" & _
            "|All Files (*.*)|*.*"
            .FilterIndex = 2
            .InitialDirectory = Application.ExecutablePath

        End With
        ofdFile.ShowDialog()
        rtbdocument.LoadFile(ofdFile.FileName, RichTextBoxStreamType.PlainText)

    End Sub

    Private Sub SaveToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
        On Error Resume Next
        With sfdSave

            .Filter = "Show All Files (*.RTF) | *.RTF" & _
                "|HTML Files (*.htm) | * .htm"
            .FilterIndex = 2
            .Title = "Filename to save"

        End With

        sfdSave.ShowDialog()
        rtbdocument.SaveFile(sfdSave.FileName, RichTextBoxStreamType.PlainText)

        wordProcessorForm.ActiveForm.Text = "Saved File" & sfdSave.FileName

        CloseToolStripMenuItem.Enabled = True

    End Sub

    Private Sub CloseToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click
        Dim intfile As Object

        rtbdocument.Text = ""

        FileClose(intfile)

    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Me.Close()

    End Sub

    Private Sub FontToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FontToolStripMenuItem.Click
        On Error Resume Next

        With fdFont

            .ShowColor = True
            .ShowApply = True

        End With

        fdFont.ShowDialog()

        rtbdocument.SelectionFont = fdFont.Font

        rtbdocument.SelectionColor = fdFont.Color

        Call Update()

    End Sub

    Private Sub ColorToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ColorToolStripMenuItem.Click
        On Error Resume Next

        cdColors.ShowDialog()

        rtbdocument.SelectionColor = cdColors.Color

    End Sub

    Private Sub PrintToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click



    End Sub

    Private Sub FindAndReplaceToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FindAndReplaceToolStripMenuItem.Click
        Dim FText As String
        Dim RText As String

        FText = InputBox("Find What: ", "Find Text")

        RText = InputBox("Replace With: ", "Replace Text")

        rtbdocument.Text = Replace(rtbdocument.Text, UCase(FText), UCase(RText))
        rtbdocument.Text = Replace(rtbdocument.Text, LCase(FText), LCase(RText))
    End Sub


    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub CopyToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        RTBdocument.Copy()

    End Sub

    Private Sub PasteToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        RTBdocument.Paste()
    End Sub

    Private Sub rtbDocument_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

   
    Private Sub PrintForm1_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintForm1.BeginPrint

    End Sub
End Class



Is This A Good Question/Topic? 0
  • +

Replies To: adding cut, copy, and paste functionality to a word processor form VB

#2 _HAWK_  Icon User is online

  • Master(Of Foo)
  • member icon

Reputation: 1062
  • View blog
  • Posts: 4,144
  • Joined: 02-July 08

Re: adding cut, copy, and paste functionality to a word processor form VB

Posted 16 March 2011 - 01:34 PM

Your code has nothing to do with your question, but you are not assigning the return value from the message box.
pintdialogresult = messagebox.show(...)


Was This Post Helpful? 1
  • +
  • -

#3 hifistyle  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 11-October 10

Re: adding cut, copy, and paste functionality to a word processor form VB

Posted 16 March 2011 - 02:54 PM

View Posthawkvalley1, on 16 March 2011 - 01:34 PM, said:

Your code has nothing to do with your question, but you are not assigning the return value from the message box.
pintdialogresult = messagebox.show(...)



Thanks.
Figured it was better to include it than not.
In the meantime, I did find a tutorial here at D-I-C.

Thanks again.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1