class question - code included in this post

G

Guest

Sorry I forgot the code (Please see below). The first time that I call this class, I populate colScrollArea. The second time that I call this class, it, for some reason that I don't see, destroys colScrollArea. Does anyone have any ideas

I am using XL 2002

TIA

Jo

Code

Private Sub Class_Initialize(
Set m_f = New frmSecurit
If colScrollArea Is Nothing The
Call populateScrollAreaCollectio
End I
End Su

Private Sub Class_Terminate(
Unload m_
Set colScrollArea = Nothin
Set m_f = Nothin
End Su

populateScrollAreaCollection is a public sub in a module and has the following code

Public Sub populateScrollAreaCollection(
Set colScrollArea = New Collectio
With colScrollAre
.Add WKS_SA_MAIN, WKS_MAI
.Add WKS_SA_ECHO, WKS_ECH
.Add WKS_SA_CATH, WKS_CAT
.Add WKS_SA_NUCLEAR, WKS_NUCLEA
.Add WKS_SA_OTHER, WKS_OTHE
.Add WKS_SA_PACS, WKS_PAC
.Add WKS_SA_SYSTEM, WKS_SYSTE
.Add WKS_SA_REVIEW, WKS_REVIE
.Add WKS_SA_NETWORK, WKS_NETWOR
.Add WKS_SA_RESULTS, WKS_RESULT
End Wit
End Su

where colScrollArea is declared as

Public colScrollArea As Collectio
 
O

onedaywhen

Seems to work for me. Perhaps there is code elsewhere (e.g. in
frmSecurity) that is having an effect? Here's my test, stripped down
to the essentials of what your posted:

'----------------------------------
'<Code in class module named Class1>
Option Explicit

Private Sub Class_Initialize()
If colScrollArea Is Nothing Then
Stop ' hard breakpoint

' Next line only fires once (correct)
Call populateScrollAreaCollection
End If
End Sub

Private Sub Class_Terminate()
Set colScrollArea = Nothing
End Sub
'</Code in class module named Class1>
'----------------------------------
'<Code in a standard module>
Option Explicit

Public colScrollArea As Collection

Sub populateScrollAreaCollection()
Set colScrollArea = New Collection
End Sub

Sub Test()
Dim c1 As Class1
Dim c2 As Class1

Set c1 = New Class1
Set c2 = New Class1
End Sub
'</Code in a standard module>
'----------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top