PC Review


Reply
Thread Tools Rate Thread

Classes and Userform: Passing it around

 
 
axwack
Guest
Posts: n/a
 
      4th Sep 2007
I created a class and a userform. The userform has certain fields of
type dates, strings, etc. all of which I set a CLASS with propertieis.
The class is created by the userform. After the user fills out the
userform, I want the class so that I can use it within my worksheet
workflow to calculate values for the worksheet.

How do I get the class after the userform is closed? Does it exist in
memory and how do I access it?

 
Reply With Quote
 
 
 
 
=?Utf-8?B?VmVyZ2VsIEFkcmlhbm8=?=
Guest
Posts: n/a
 
      5th Sep 2007
You could expose a public property in the user form that you can use to point
to an object variable that is defined in the worksheet. In this way, the
userform would be manipulating an object that actually exists in the
worksheet. When the userform is unloaded, the object would still be
available in the worksheet.

Or, you can also declare the object variable with a global scope. For
example, in a module, declare it like this

Global obj as New YourClass

You can then access that variable anywhere in your VBA code.



--
Hope that helps.

Vergel Adriano


"axwack" wrote:

> I created a class and a userform. The userform has certain fields of
> type dates, strings, etc. all of which I set a CLASS with propertieis.
> The class is created by the userform. After the user fills out the
> userform, I want the class so that I can use it within my worksheet
> workflow to calculate values for the worksheet.
>
> How do I get the class after the userform is closed? Does it exist in
> memory and how do I access it?
>
>

 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      5th Sep 2007
Declare the class in the code that launches the userform, then pass the
class to the userform as a property. Here's a simple example of userform
properties:

http://peltiertech.com/Excel/PropertyProcedures.html

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"axwack" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I created a class and a userform. The userform has certain fields of
> type dates, strings, etc. all of which I set a CLASS with propertieis.
> The class is created by the userform. After the user fills out the
> userform, I want the class so that I can use it within my worksheet
> workflow to calculate values for the worksheet.
>
> How do I get the class after the userform is closed? Does it exist in
> memory and how do I access it?
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing events between different classes Tom Microsoft C# .NET 9 26th Jul 2007 09:36 PM
Passing KeyEvents to other classes Uchiha Jax Microsoft C# .NET 0 21st Apr 2005 11:30 PM
Passing arrays between classes Rik Microsoft VB .NET 7 21st Mar 2005 09:25 AM
Passing Parameters between form classes - C# =?Utf-8?B?Sm9obm55?= Microsoft C# .NET 11 8th Feb 2005 03:55 PM
Passing Classes RBCC Microsoft VB .NET 6 26th Feb 2004 04:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:22 AM.