×
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

Passing collection to comand button

Passing collection to comand button

Passing collection to comand button

(OP)
Hi all ,

Could someone help me please with achieving following :
I have :

1.subroutine:
-inside code....
then i have 2 new collections inside wich i passed from other subroutine by calling the first one .

The problem is i want to pass this 2 collections to a command button,see picture attached.

what i am trying to say is , only after i press the button those 2 collection to pass to other subroutine.

Will appreciate any suggestion,thank you!

RE: Passing collection to comand button

It isn't clear to me what you are trying to do. Could you list (in text, in the message) the steps you want the code to follow.

Also note that you can post code in the message, using the "Code" icon above the edit box.

Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/

RE: Passing collection to comand button

What's the scope of nwcol2 & nwcol. If you're hoping to press a button on the sheet, you'll need to initialise those variables within the button code. Unless they have a global or public scope and they have already been initialised, might work then.

Hard to say because the code is incomplete in that you have not provided how those variables are initialised, only a snippet provided at the top of your screenshot.

RE: Passing collection to comand button

(OP)
Hi all ,

Thank you for your support.
The code is a long one , but i just made a simple one for you to understand what i want to achieve :

Public Sub CommandButton1_Click()

Dim a, b, c As String

a = "hi"
b = "hope you are doing well"
c = "thank you for help"

ListBox1.AddItem a
ListBox1.AddItem b
ListBox1.AddItem c

Dim nwcol As Collection
Set nwcol = New Collection

nwcol.Add (a & b & c)

End Sub

Public Sub CommandButton2_Click(ByRef nwcol As Collection)

ListBox2.AddItem nwcol.Item(1)

End Sub

So you can see that i want to pass the nwcol to second button and to be listed in listbox2 , but only when second button will be pressed.
Many thanks!




RE: Passing collection to comand button

Options are:

1) Copy the CommandButton1_Click code to a function that returns nwcol. You can then call that from either Button1 or Button2.

2) Write nwcol to a named spreadsheet range. You can then read that in the CommandButton2_Click code.

3) As Agent666 suggested, make nwcol a global variable. It will than be available inside CommandButton2_Click.

As far as I know you can't pass arguments to routines called from a command button.

Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/

RE: Passing collection to comand button

(OP)
Thank you for suggestions !

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