Multiple textboxes Cut,Copy,Paste question 
Author Message
 Multiple textboxes Cut,Copy,Paste question

Hello all

What is the code for "copy , cut, past"
if you have multiple textboxes on your form?

The code I have now for copy is..
clipboard.seltext text1.seltext
(text1 being the name of one of the 5 textboxes
on the form)
This does work but just for that textbox
it won't let me copy from anyother textbox.

What is the code to do this for multiple
textboxes on the form?

And if possable what would be the code for
the "cut and Paste"

Thanks in advance


Thu, 12 Apr 2001 02:00:00 GMT  
 Multiple textboxes Cut,Copy,Paste question
From VB3 Help file:


ActiveForm, ActiveControl Properties Example 2

The example shows how you can use the Clipboard in cut, copy, paste, and delete operations using buttons on a toolbar.  To
try this example, draw a text box and a check box on Form1, then create a new MDI form.  On the MDI form, draw a picture box
and then draw a command button in the picture box.  Set the Index property on the command button to 0 (this creates a control
array).  On Form1, set the MDIChild property to True.
To run the example, copy the code into the Declarations section of the MDI form and press F5.  Notice that if the check box
has the focus, the buttons don't work.

Sub MDIForm_Load ()
        Dim I                                           ' Declare variable.
        Command1(0).Move 0, 0, 700, 300 ' Position button on toolbar.
        For I = 1 To 3  ' Create other buttons.
                Load Command1(I)        ' Create button.
                Command1(I).Move I * 700, 0, 700, 300   ' Place and size button.
                Command1(I).Visible = True      ' Display button.
        Next I
        Command1(0).Caption = "Cut"   ' Set button captions.
        Command1(1).Caption = "Copy"
        Command1(2).Caption = "Paste"
        Command1(3).Caption = "Del"
End Sub

Sub Command1_Click (Index As Integer)
        ' ActiveForm refers to the active form in the MDI form.
        If TypeOf ActiveForm.ActiveControl Is TextBox Then
                Select Case Index
                        Case 0                  ' Cut.
                                ' Copy selected text to Clipboard.
                                Clipboard.SetText ActiveForm.ActiveControl.SelText
                                ' Delete selected text.
                                ActiveForm.ActiveControl.SelText = ""
                        Case 1                  ' Copy.
                                ' Copy selected text to Clipboard.
                                Clipboard.SetText ActiveForm.ActiveControl.SelText
                        Case 2                  ' Paste.
                                ' Put Clipboard text in text box.
                                ActiveForm.ActiveControl.SelText = Clipboard.GetText()
                        Case 3                  ' Delete.
                                ' Delete selected text.
                                ActiveForm.ActiveControl.SelText = ""
                End Select
        End If
End Sub

FYI: Look under the Edit menu in your copy of VB, note the shortcuts they use.
Those keyboard commands are already supported for your textboxes, are they not?

Fri, 13 Apr 2001 03:00:00 GMT  
 [ 2 post ] 

 Relevant Pages 

1. Cut, paste, copy questions...

2. Cut, Copy, Paste

3. How can I copy records like cut-n-paste

4. disabling cut/copy/paste

5. disabling copy/paste/cut on shape shortcut menu

6. Cut,Copy,Paste

7. prevent cut-n-paste into textbox

8. cut, copy and paste

9. cut copy and paste

10. Cut, Copy and Paste in the menu bar

11. Help Cut/Copy & Paste

12. cut, copy, and paste


Powered by phpBB® Forum Software