CodeItBetter Programming Another VB Programming Blog

This subroutine processes the cut, copy and paste commands.

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'Forms - This subroutine processes the cut, copy and paste commands.
'Function: CutCopyPaste(DoWhat As Integer)
'Description: This sub processes the cut, copy and paste commands.
'Parameters: 0=cut, 1=copy, 2=paste, 3=delete
'Notes:
'Returns: Nothing
Sub CutCopyPaste(DoWhat As Integer)
    ' ActiveForm refers to the active form in the MDI form.
    If TypeOf Screen.ActiveControl Is TextBox Then
        Select Case DoWhat
        Case 0                      ' Cut.
            ' Copy selected text to Clipboard.
            Clipboard.SetText Screen.ActiveControl.SelText
            ' Delete selected text.
            Screen.ActiveControl.SelText = ""
        Case 1                      ' Copy.
            ' Copy selected text to Clipboard.
            Clipboard.SetText Screen.ActiveControl.SelText
        Case 2                      ' Paste.
            ' Put Clipboard text in text box.
            Screen.ActiveControl.SelText = Clipboard.GetText()
        Case 3                      ' Delete.
            ' Delete selected text.
            Screen.ActiveControl.SelText = ""
        End Select
    End If
End Sub

Related posts:

  1. How to enable or disable the Cut, Copy and Paste menus in Edit menu if the text selected or not in a control.
  2. How to copy/cut the content of the text box to the clipboard
  3. How to enable/disable submenus of Edit menu (Copy, Cut, Clear, Undo, and so on) based on text selection
  4. How to Copy and Paste the Picture
  5. How to set text into Clipboard
  6. How to Paste the Picture from PictureBox/Clipboard to Rich Text Box
  7. How to Copy data from an Access database into an Excel spreadsheet using a SQL SELECT statement
  8. How to keep your Background Processes running when displaying Message Box
  9. How to find out how the form is unloading
  10. Form Text Box Control Navigation

Filed under: Forms Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.