Results 1 to 4 of 4

Thread: Creating Cut, Copy, and Paste Features in a Editor

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    69

    Cool

    Hey guys,

    I am creating an editor of my own for a VB project. I have been able to implement New, Open and Exit commands successfully. But I am stuck with Cut, Copy, Paste and Delete features of the Implementation.
    Do you guys have an suggestions on how to implement the cut, copy, paste, and delete actions(Even the logic aspect will be sufficient)? Thank you in advance.


    Manoj

  2. #2
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Lightbulb

    Hi sweetsupra,

    Look into using the Clipboard object. That's where I would start.

    All the best.

  3. #3
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    OneSource is correct, the best way to do this is with the Clipboard. Here's the code (unabashedly stolen from a textbook by Diane Zak, "Programming with Microsoft Visual Basic X.0" (X.0 = 4.0, 5.0, 6.0 etc.) - great book for beginners, btw).
    The following code assumes that you have a menu item named "mnuEdit" with sub-items named "mnuCopy", "mnuCut", "mnuPaste", and "mnuDelete", and that your textbox is called txtEdit:
    Code:
    Private Sub mnuEdit_Click()
        ' enable/disable copy and cut commands, depending
        ' on whether any text is selected ...
        If txtEdit.SelText = "" Then
            mnuCut.Enabled = False
            mnuCopy.Enabled = False
        Else
            mnuCut.Enabled = True
            mnuCopy.Enabled = True
        End If
        ' enable/disable Paste command, depending on
        ' whether or not any text is in the Clipboard ...
        If Clipboard.GetText() = "" Then
           mnuPaste.Enabled = False
        Else
           mnuPaste.Enabled = True
        End If
    
    End Sub
    
    Private Sub mnuCopy_Click()
        Clipboard.Clear
        Clipboard.SetText txtEdit.SelText
    End Sub
    
    Private Sub mnuCut_Click()
        Clipboard.Clear
        Clipboard.SetText txtEdit.SelText
        txtEdit.SelText = ""
    End Sub
    
    Private Sub mnuPaste_Click()
        txtEdit.SelText Clipboard.GetText()
    End Sub
    
    Private Sub mnuDelete_Click()
        txtEdit.SelText = ""
    End Sub
    "It's cold gin time again ..."

    Check out my website here.

  4. #4
    Junior Member
    Join Date
    May 2003
    Location
    India
    Posts
    16
    Try the Visual Basic Application Wizard first.I learnt a lot of things from it. File->New Project. then VB Application Wizard.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width