I treat Userforms as Class Modules without problems. It find it tider than
returning values via a Standard Module.
--
Rob van Gelder -
http://www.vangelder.co.nz/excel
"keepITcool" wrote in message
...
ok i confirm it crashed in xlXP too :)
but what's the point?
the PROBLEM is that
you're treating a userform as a class module (first time i saw that :)
keepITcool
< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool
"David Battams" wrote:
Hi,
I have a problem in some VBA code that causes a hard crash in Excel
2000 and 2003 (haven't tried Excel XP but I would assume the same
result). Fortunately I managed to reproduce the problem in a simple
workbook, and the code is that small that I can duplicate it here.
In a new workbook, add the following:
ThisWorkBook
Public Sub EntryPoint()
Dim data() As MY_DATA_TYPE
ReDim data(0)
data(0).val1 = "Test"
data(0).val2 = "Test 2"
MethodA data
End Sub
Private Sub MethodA(ByRef data() As MY_DATA_TYPE)
Dim form As UserForm1
Set form = New UserForm1
form.Test = data
End Sub
Module1
Public Type MY_DATA_TYPE
val1 As String
val2 As String
End Type
UserForm1
Private m_data() As MY_DATA_TYPE
Public Property Let Test(ByRef newValue() As MY_DATA_TYPE)
m_data = newValue
End Property
The code will crash when setting the Test property of UserForm1
This only seems to occur in this particular configuration of code. I
can pass the dyamic array through a number of methods without issue,
but when I assign the UserForm property is when it fails. It will also
work fine if I short circuit MethodB and set the UserForm property
directly from the EntryPoint method. Yet another way to get it to work
is to make the dynamic array a module level variable in ThisWorkBook
and thus not have to pass it between methods in ThisWorkbook.
I do have a work around so am not being held up by this, but I would
be appreciative if someone from Microsoft (or otherwise) could confirm
this behavior and advise whether it is a bug or known limitation. I
couldn't find anything in the KB about it.
Kind Regards,
Wayne.