View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Reproducable Hard Crash in Excel 2003 (and earlier versions) with the following VBA code.

Wayne,

although my first remark wasn't well received.. let me try again :)

crash appears to be caused by invoking a property let procedure with
an argument defined as a dynamic ARRAY of userdefined type.
Regardless of what happens inside the procedure.. the moment it's passed
to the proc the crash occurs in oleaut32

Workaround:
dim it as a class, pass it as a variant


I've changed the class varariables to public for simplicity

'Class Module clsTest
Public patternLabel As String
Public reason As String

'Object module userform1
Private m_cls() As clsTest
Public Property Let TestVariant(newData)
m_cls = newData
End Property
Public Property Let TestTyped(newData As clsTest)
'note this 'ought' to be a Property SET
ReDim m_cls(0)
Set m_cls(0) = newData
End Property
Public Property Let TestArray(newData() As clsTest)
m_cls = newData
End Property
'code module1
Public Sub EntryPoint()
Dim data() As clsTest
ReDim data(0)
Set data(0) = New clsTest
data(0).patternLabel = "Test1"
data(0).reason = "Test2"
fillFORM data
End Sub

Private Sub fillFORM(data() As clsTest)
Dim form As UserForm1
Set form = New UserForm1
form.TestVariant = data
MsgBox "Variant successfull"

Let form.TestTyped = data(0)

MsgBox "Class successfull"

If vbOK = MsgBox("Fasten seatbelts", vbOKCancel) Then
form.TestArray = data
MsgBox "You wont see this one ...."
End If
End Sub




keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"David Battams" wrote:

Hi again Jamie,

Tried the VB object route - here's my 2 second class:

...[snip]

but just like the with the data type I still got the hard crash in
Excel :-(

Something for Microsoft I guess......

Regards,
Wayne.




"David Battams" wrote in message
...
Hi Jamie,

My comment about the UserForm being an object module was that there
is no need to "pretend" its like an object module since it is one.
Rob is using it correctly It's just a special type of class module.

I might try the idea of using a class object in lieu of a type and
let you know how it goes. I am writing VBA code against a set of
custom COM components, but the data type I am having the problem with
is used purely within the VBA world, so I have the freedom to change
it to a VBA class instead. Good thinking and I'll let you know how it
goes.

Cheers,
Wayne.

[..snip]