×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

copy a variable to clipboard and pass it to an other sub

copy a variable to clipboard and pass it to an other sub

copy a variable to clipboard and pass it to an other sub

(OP)
dear colleagues...

I am having a very big problem.

Is anybody who knows how can i use the results from a FORM to an other?

I had to create several dialog boxes (forms) and the thing is that i need to pass some results from one to the other... WITHOUT WRITING THE DATA IN ANY CELLS. The data has to be written in the variable and registered to clipboard and call backed form/by an other subroutine.

Thank you very much for all your help.

Florin

RE: copy a variable to clipboard and pass it to an other sub

Not sure about the terminology.  When you say form do you mean form in the same program or form in a different program.

case 1
program A pops up form B
some data is entered
user hits a button
program A pops up form C with data entered from form B

case 2
program A pops up form B
program D pops up form C
some data is entered
user hit a button
data is transferred from form B to form C

RE: copy a variable to clipboard and pass it to an other sub

Either way you can use the Clipboard Object.

CODE

Private Sub CmdMyCopy_Click()
Clipboard.Clear
Clipboard.SetText Text1.Text
End Sub

Private Sub CmdMyPaste_Click()
Text2.Text = Clipboard.GetText(vbCFText)
End Sub
VBHelp has more details on clipboard modes (text, image etc)

Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376: Eng-Tips.com Forum Policies before posting
Steam Engine enthusiasts
Steam Engine Prints

RE: copy a variable to clipboard and pass it to an other sub

(OP)
Dear xwb,

I have a macro. In this macro I am having 2 dialog boxes. One asks the user to input some data. One of the data is the date start and end of a task. In order to do so I've added a button that calls for calendar window.

When the user selects the date and pushes ADD button the date has to be written in the appropriate TextBox (on the main FORM). When the user inserted all data then he hits OK button.
After this all the data in the FORM are written to excel (in specific cells). Until now the only way i've manage to do this is by writing the date into a cell and make the TextBox load it from there.

With all this I am convinced that there should be a way of putting this Date into clipboard and load it to the TextBOX. Afterwards, when OK button is pushed,  it will be added to the excel cell.

Those are all the details for this particular task that i have to perform.  

Thank you very much.
If you have any idea please do not hesitate.

RE: copy a variable to clipboard and pass it to an other sub

(OP)
johnwm thank you too.

Unfortunately the VBA gives error msg when I am trying to use the sequence you've written.

It does not accept

Clipboard.Clear
Clipboard.SetText Text1.Text
like commends.

I also tried to create a new form (in respect with what u've used)and the error seems to be the same.

Thanks.
Do u have any idea of what is going on?  

RE: copy a variable to clipboard and pass it to an other sub

Ursy,

clipboard in VBA is more tricky to use.

try form2.textbox.text = (form1.)textbox.text

Regards,

Regg

RE: copy a variable to clipboard and pass it to an other sub

Sorry - this is the Visual Basic Forum, so I gave the Visual Basic answer. For VBA questions you will do better in forum766: Microsoft VBA - Visual Basic for Applications as it will avoid these problems. However if this is indeed a VBA question, a quick browse through the helpfile will find 'PutInClipboard' with a full example

Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376: Eng-Tips.com Forum Policies before posting
Steam Engine enthusiasts
Steam Engine Prints

RE: copy a variable to clipboard and pass it to an other sub

You do not need clipboard.

If there are variables in a form that you need to pass along, declare them as Public.

When you hide a form, all of its data is still available.  You can query the public variables.  It is not until you unload a form that the data is lost.

Below: code from one of my macros that gets data from two form variables before unloading...

CODE

frmFeatureSelection.Show vbModal
SelFilter = frmFeatureSelection.SelectSum
If Not frmFeatureSelection.OKFlag Then Unload frmFeatureSelection: End
Unload frmFeatureSelection

batHonesty may be the best policy, but insanity is a better defense.bat
http://www.EsoxRepublic.com-SolidWorks API VB programming help

RE: copy a variable to clipboard and pass it to an other sub

(OP)
Thank you all .. for your prompt answers.

And.. my apologies for posting it on the wrong forum.

Thank you very much. Now the problem is solved.
It works also with the clipboard as well as by using the public variable.

  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close