VB6: Copy, Cut & Paste from/to TextBox in MDI form?

Hi,

When I try to Copy, Cut or Paste from or to TextBox in my MDI child form I am getting an Error. Does it make any diferent to Copy/Paste from/to an MDI form?

Thank you.
LVL 2
2AngelAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
anvConnect With a Mentor Commented:
alright then...

use this then

MDIForm1.ActiveControl.Text = Clipboard.GetText
0
 
DhaestCommented:
Can you post a piece of your code and the error you're getting !
0
 
2AngelAuthor Commented:
Hi,
I tried both methods:
The simple one
                 Clipboard.SetText
Or this one
                 http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/viewQuestionPrinterFriendly.jsp?qid=20561050

The error on both methods is: "Argument not optional"

Thanks
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
anvCommented:
hi

did u try this..

Private Sub Command1_Click()
'copy

Clipboard.SetText ("SomeTextToCopyFrom HERE")

End Sub

Private Sub Command2_Click()
'Paste
   Text1.Text = Clipboard.GetText()
End Sub
0
 
2AngelAuthor Commented:
Hi,

Thank you for your comment, any, but I did. This is working but its not giving me the solustion.
I want to Copy/Paste to the control that the user is "standing on" (the TextBox that is in focus).

Thanks.
0
 
2AngelAuthor Commented:
Hi,

Thanks again...

This time I don't recive the error but it's doesn't do anything...
ByTheWay, The Paste (MDIForm1.ActiveControl.Text = Clipboard.SetText) is giving me the error above....

Please, my you have another one....

P.S. - Your Registration Date is on my Birthdate....

Thanks!
0
 
anvCommented:
where did u write the code for above statement?? i mean in shich event are u calling it...

actually ActiveControl is the control of the form that currently has the focus...

so if u are giving the code in the click event of a command button...then u need to set the focus to the control or text box...first..then u need to execute the above statement..
0
 
anvCommented:
>>P.S. - Your Registration Date is on my Birthdate....

Good to know that..

:))
0
 
2AngelAuthor Commented:
Hi,

The statement is under the menu Copy...
The control is on focus becaose I click on a control, mark the data and then click on the menu->copy (or Ctrl+C).

p.s. - "Neeru Verma" What is the source of this name? Does it has a meaning?

Regards.
0
 
anvCommented:
hi 2Angel
it should work

as its working here very smoothly...

can u paste the code here

>>p.s. - "Neeru Verma" What is the source of this name? Does it has a meaning?

"Verma" is my husband's Last Name
in hindi "Neer" means "Water".. "Neeru" means "Holy Water"
0
 
jimbobmcgeeConnect With a Mentor Commented:
If ActiveControl is the control that has focus, perhaps clicking the menu item is shifting the focus to the menu.  Maybe the Click event of the menu is run _before_ the focus is passed back to the text box.

If that is the case, perhaps:

       Public ctlLastControl as Control

       Private Sub Text1_LostFocus()

            Set ctlLastControl = Text1

       End Sub

       Private Sub mnuCopy_Click()

           Clipboard.Clear
           Clipboard.SetText ctlLastControl.Text

       End Sub

       Private Sub mnuPaste_Click()

           Clipboard.Clear
           ctlLastControl.Text = ctlLastControl.Text & Clipboard.GetText

       End Sub


Incidently, are you clearing the clipboard before you set your text?  

Or are you perhaps saying:

       Clipboard.SetText Text1.Text
       ...
       Text1.Text = Clipboard.GetText

because, if you are, then Text1.Text will appear not to change...

Just some ideas; HTH...

J.
0
 
2AngelAuthor Commented:
Wow - very interesting about you name.

>>"Verma" is my husband's Last Name
again wow - you are only 24....


Well, my code is very simple. I have an MDI Main form (frmMain) and MDIChild (frmTable).
frmTable has a few TextBoxs named txtBx(0).... and so on... (this form is connected to an access data base).
The main form has a menu I've created by the MenuEditor.

So, I have this code on the main form:

Private Sub mnuEditCopy_click()
     frmTable.ActiveControl.Text = Clipboard.GetText
End Sub

Private Sub mnuEditPaste_click()
     Clipboard.SetText frmTable.ActiveControl.Text
End Sub


Thank you for helping and have a nice day...

0
 
Erick37Connect With a Mentor Commented:
Do you have this reversed?
Copy should copy to clipboard
Paste should paste to control

Private Sub mnuEditCopy_click()
    Clipboard.SetText frmTable.ActiveControl.Text
End Sub

Private Sub mnuEditPaste_click()
    frmTable.ActiveControl.Text = Clipboard.GetText
End Sub
0
 
2AngelAuthor Commented:

O.K. - I am sorry, I got it......

The problem was that this is an MDI application and I need to look for the active form first...   so, I this is the answere:

Private Sub mnuEditCopy_click()
    Clipboard.SetText ActiveForm.ActiveControl.Text
End Sub

Private Sub mnuEditPaste_click()
    ActiveForm.ActiveControl.Text = Clipboard.GetText
End Sub

Well, thanks every one!!! Anyhow I will split the points

p.s. - Neeru Verma, take care......
0
 
anvCommented:
thanx 2Angel

:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.