Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Status
Not open for further replies.

Ursy

New member
Jan 15, 2007
7
0
0
DE
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

 
Replies continue below

Recommended for you

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
 
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 before posting
Steam Engine enthusiasts
Steam Engine Prints
 
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.
 
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?
 
Sorry - this is the Visual Basic Forum, so I gave the Visual Basic answer. For VBA questions you will do better in forum766 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 before posting
Steam Engine enthusiasts
Steam Engine Prints
 
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

[bat]Honesty may be the best policy, but insanity is a better defense.[bat]
-SolidWorks API VB programming help
 
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.

 
Status
Not open for further replies.
Back
Top