Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How to create Singleton Pattern in VBA?

Hi,

I am a newbie in VBA. This is first time I try to use customer classes
in VBA. I want to know whether it is possible to create Singleton
Pattern in VBA?

For example, in java we can do this:

public class MyClass {
private static MyClass instance;
private MyClass() {}
public static MyClass getInstance() {
if (instance==null)
instance=new MyClass();
return instance;
}
}

Such that we can call: MyClass.getInstance() to retrieve the same
reference all the time.

Does anyone know how to do it in VBA?

Thanks a lot.

Paul

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default How to create Singleton Pattern in VBA?

Given that the only types of instancing on VBA classes is Private and
PublicNotCreatable, the WB containing the class could control its creation.
As I understand it, as each instance of the class gets its own local data,
such a concept as below does not exist natively in VBA.

NickHK

"Paul" wrote in message
oups.com...
Hi,

I am a newbie in VBA. This is first time I try to use customer classes
in VBA. I want to know whether it is possible to create Singleton
Pattern in VBA?

For example, in java we can do this:

public class MyClass {
private static MyClass instance;
private MyClass() {}
public static MyClass getInstance() {
if (instance==null)
instance=new MyClass();
return instance;
}
}

Such that we can call: MyClass.getInstance() to retrieve the same
reference all the time.

Does anyone know how to do it in VBA?

Thanks a lot.

Paul



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Want to keep the pattern, not the fill meems Excel Discussion (Misc queries) 2 September 14th 09 06:38 PM
Recurring pattern LaDdIe Excel Worksheet Functions 2 March 9th 07 09:25 PM
Get rid of pattern smackedass Excel Discussion (Misc queries) 1 October 1st 06 12:38 AM
how do i add a pattern to cells skater_element_2008 Excel Discussion (Misc queries) 2 February 10th 06 04:07 PM
Pattern Files Paul Kirnig Excel Programming 1 December 30th 03 08:48 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"