Link to home
Start Free TrialLog in
Avatar of 2Angel
2Angel

asked on

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.
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Can you post a piece of your code and the error you're getting !
Avatar of 2Angel
2Angel

ASKER

Hi,
I tried both methods:
The simple one
                 Clipboard.SetText
Or this one
                 https://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/viewQuestionPrinterFriendly.jsp?qid=20561050

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

Thanks
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
Avatar of 2Angel

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of anv
anv

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 2Angel

ASKER

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!
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..
>>P.S. - Your Registration Date is on my Birthdate....

Good to know that..

:))
Avatar of 2Angel

ASKER

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.
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"
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 2Angel

ASKER

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...

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 2Angel

ASKER


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......
thanx 2Angel

:)