473,569 Members | 2,984 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why is Class_Terminate method being invoked?

I'm trying to convert some VBA routines in an Excel 2000 workbook to use
objects instead of global varaibles. I've defined a class module with
the following (excerpts):

(from SheetMetrics class module)
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~
Private m_HoldingSheetN ame As String
Private m_rngFundSymbol s As Range
*
*
Option Explicit
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~
Private Sub Class_Initializ e()
m_HoldingSheetN ame = ""
*
*
End Sub
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~
Private Sub Class_Terminate () <==being invoked in error
Set m_rngFundSymbol s = Nothing
End Sub
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~
Public Property Let SheetName(Sheet ID As String)
If Not SheetID = "" Then
m_HoldingSheetN ame = SheetID
End If
End Property
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~
Public Property Get SheetName() As String
SheetName = m_HoldingSheetN ame
End Property
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~
Public Property Let SymbolRange(Sym bRange As Range)
Set m_rngFundSymbol s = SymbRange
End Property
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~
Public Property Get SymbolRange() As Range
Set SymbolRange = m_rngFundSymbol s
End Property
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~
In a worksheet code module I attempt the following (PECategories is a
named range on the worksheet):
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~
Dim AcctSheet(4) As SheetMetrics <== class module above

Set AcctSheet(1) = New SheetMetrics
Set AcctSheet(2) = New SheetMetrics
Set AcctSheet(3) = New SheetMetrics
Set AcctSheet(4) = New SheetMetrics

AcctSheet(1).Sh eetName = "PE Holdings"
AcctSheet(1).Sy mbolRange = Range("PECatego ries") <==problem
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~

When the last statement above SHOULD execute, the
Class_Terminate method kicks off instead.

I'm stumped - would be grateful for any suggestions what is causing this
to happen...

Jul 17 '05 #1
1 5457
Please disregard, I found the problem (the range being referenced wasn't
on the sheet that owned the code being executed).

On Thu, 16 Oct 2003 04:48:57 GMT, Enigman O'Maly <No***@Home.com > wrote:
I'm trying to convert some VBA routines in an Excel 2000 workbook to use
objects instead of global varaibles. I've defined a class module with
the following (excerpts):

(from SheetMetrics class module)
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~
Private m_HoldingSheetN ame As String
Private m_rngFundSymbol s As Range
*
*
Option Explicit
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~
Private Sub Class_Initializ e()
m_HoldingSheetN ame = ""
*
*
End Sub
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~
Private Sub Class_Terminate () <==being invoked in error
Set m_rngFundSymbol s = Nothing
End Sub
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~
Public Property Let SheetName(Sheet ID As String)
If Not SheetID = "" Then
m_HoldingSheetN ame = SheetID
End If
End Property
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~
Public Property Get SheetName() As String
SheetName = m_HoldingSheetN ame
End Property
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~
Public Property Let SymbolRange(Sym bRange As Range)
Set m_rngFundSymbol s = SymbRange
End Property
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~
Public Property Get SymbolRange() As Range
Set SymbolRange = m_rngFundSymbol s
End Property
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~
In a worksheet code module I attempt the following (PECategories is a
named range on the worksheet):
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~
Dim AcctSheet(4) As SheetMetrics <== class module above

Set AcctSheet(1) = New SheetMetrics
Set AcctSheet(2) = New SheetMetrics
Set AcctSheet(3) = New SheetMetrics
Set AcctSheet(4) = New SheetMetrics

AcctSheet(1).Sh eetName = "PE Holdings"
AcctSheet(1).Sy mbolRange = Range("PECatego ries") <==problem
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~

When the last statement above SHOULD execute, the
Class_Terminat e method kicks off instead.

I'm stumped - would be grateful for any suggestions what is causing this
to happen...


Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
6689
by: A Ratcliffe | last post by:
As you might have gathered from the Subject, I've been experimenting with using VBScript classes in my ASP pages to tidy the script up. Generally things are going well. Since I come from a C++ background, I have long made use of singleton objects, in various forms, and I can see an obvious use for one here but not sure if I can. I'll...
8
6617
by: Rakehs | last post by:
Hi, I have a method Show() which is invoked by several methods at different intervals. I want to identify the calling method within Show() whenever it is invoked. How do i do this? Thanks in advance Rakesh
7
2036
by: Gaetan | last post by:
I would like to extend the capabilities of my application by calling a user method residing in a client provided assembly without having to recompile my application. Things would work like this: 1- Read a configuration file where the client provides the assembly name (DLL) and the method name. 2- Detect the existence of the assembly...
1
2410
by: Michael D. Ober | last post by:
Is there anyway to force the equivalent to VB 6's Class_Terminate event when a class object goes out of scope. I have several classes in VB 6 that depend on the Class_Terminate event firing as soon as the class variable goes out of scope and need to be able to duplicate this functionality in VB 2005. Thanks, Mike Ober.
1
1531
by: John F | last post by:
Hello, I'm dynamically loading a child form saved in a DLL. I have this code working and it's pretty straightforward. What I'd like to do is pass an object type to an invoked method in the child form as soon as it's loaded. It seems I can get the invoke working just fine, but I can't get the object successfully cast inside the invoked...
8
3849
by: Gaetan | last post by:
Is is possible in C# to have the equivalent of an array of function pointers in C? I have a situation where a top level class exposes methods like Add, Delete, ... and a few child classes with the same methods. Depending on a configuration parameter, the child method will be invoked when the top level class is invoked. I would like to...
4
1714
by: ddtl | last post by:
Hello everybody. Consider the following code: class A(object): def met(self): print 'A.met' class B(A): def met(self):
5
3100
by: rn5a | last post by:
The .NET 2.0 documentation states the following: When using a DataSet or DataTable in conjunction with a DataAdapter & a relational data source, use the Delete method of the DataRow to remove the row. The Delete method marks the row as Deleted in the DataSet or DataTable but does not remove it. Instead when the DataAdapter encounters a row...
7
1559
by: Nick | last post by:
Hi there, Is it possible to tell how a WebMethod was invoked? For example I would like to determin if it was invoked via SOAP or HTTP Post. Other than creating 2 methods I am no sure if I can do this. Many thanks for your time. Nick.
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7619
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5228
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
950
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.