View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Stephen Bullen[_4_] Stephen Bullen[_4_] is offline
external usenet poster
 
Posts: 205
Default Excel 2000 very unstable as a development environment

Hi Rob,

private m_ZincApp As New ZincApp (private variable of App
class)
Private Sub Class_Initialize()
m_ZincApp.ParentApp = Me (2nd method of executing CRASHES
here with a memory can't be read exception)

.....entering ZincApp class...
Private m_ParentApp As IZincApp
Property Let ParentApp(RHS As IZincApp)
Set m_ParentApp = RHS


If I'm reading this correctly, you have a class that defines an interface
IZincApp. You have a class called App that implements the IZincApp interface,
but also has a child class called ZincApp. When App instantiates ZincApp, you
want to pass it a reference to the App class, so some code within ZincApp can
call back into App?

If so, you might find it more stable to use a Property Set ParentApp instead
of a Property Let, and it's best practice to instantiate classes when they're
needed, rather than declaring them 'As New':

Class IZincApp (defines the IZincApp interface)
==============
Public Sub CallBack()
End Sub


Class App (parent class, implementing the IZincApp interface)
=========
Implements IZincApp
Private m_ZincApp As ZincApp

Private Sub Class_Initialize()
Set m_ZincApp = New ZincApp
Set m_ZincApp.ParentApp = Me
End Sub

Private Sub IZincApp_CallBack()
End Sub


Class ZincApp (child class, calling back via the IZincApp interface)
=============
Private m_ParentApp As IZincApp
Public Property Set ParentApp(RHS As IZincApp)
Set m_ParentApp = RHS
End Property

Public Sub SomeMethod()
m_ParentApp.CallBack
End Sub


Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk