Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Userform.Caption is blank when reference passed to class

'** In MyClass.cls
Private XLUForm As UserForm
Public Property Set XLUserForm(vData As UserForm)
Set XLUForm = vData
End Property

'**Called from a userform called MyForm
Set MyClass.XLUForm=MyForm

Using the above code in a class in same WB as the passed UserForm,
vData.Caption always evaluates to "".
But if, whilst in the class, I test ?MyForm.Caption it returns the correct
value.
Also, properties like vData.Width are no longer "supported", but
..InsideWidth is.

If I change the declarations to:
Private XLUForm As MyForm
Public Property Set XLUserForm(vData As MyForm)

everything is *normal*.

Anyone explain why ?

NickHK


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Userform.Caption is blank when reference passed to class

A generic userform object has very few properties. Most
properties are created when the form is created.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"NickHK" wrote in message
...
'** In MyClass.cls
Private XLUForm As UserForm
Public Property Set XLUserForm(vData As UserForm)
Set XLUForm = vData
End Property

'**Called from a userform called MyForm
Set MyClass.XLUForm=MyForm

Using the above code in a class in same WB as the passed
UserForm,
vData.Caption always evaluates to "".
But if, whilst in the class, I test ?MyForm.Caption it returns
the correct
value.
Also, properties like vData.Width are no longer "supported",
but
.InsideWidth is.

If I change the declarations to:
Private XLUForm As MyForm
Public Property Set XLUserForm(vData As MyForm)

everything is *normal*.

Anyone explain why ?

NickHK




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Userform.Caption is blank when reference passed to class

Chip,
So if I wanted a generic routine in a class to deal with userforms e.g
'**MyFormClass
Public Function ReadCaption (argUserForm as UserForm)
MsgBox argUserForm.Caption
End Function

Calling this from a cmd on a userform:
Dim cFormHandler As MyFormClass
cFormHandler.ReadCaption Me

This will never work then because the object does not have such a property.
I can't create routines for every userform used, passing in the speciifc
userform, as in
Public Function ReadCaption (argUserForm as UserForm1)...
Public Function ReadCaption (argUserForm as UserForm2)...etc

NickHK


"Chip Pearson" wrote in message
...
A generic userform object has very few properties. Most
properties are created when the form is created.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"NickHK" wrote in message
...
'** In MyClass.cls
Private XLUForm As UserForm
Public Property Set XLUserForm(vData As UserForm)
Set XLUForm = vData
End Property

'**Called from a userform called MyForm
Set MyClass.XLUForm=MyForm

Using the above code in a class in same WB as the passed
UserForm,
vData.Caption always evaluates to "".
But if, whilst in the class, I test ?MyForm.Caption it returns
the correct
value.
Also, properties like vData.Width are no longer "supported",
but
.InsideWidth is.

If I change the declarations to:
Private XLUForm As MyForm
Public Property Set XLUserForm(vData As MyForm)

everything is *normal*.

Anyone explain why ?

NickHK






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Userform.Caption is blank when reference passed to class

This worked for me.

Public Function ReadCaption(argUserForm As Object)

Cheers
Andy

NickHK wrote:
Chip,
So if I wanted a generic routine in a class to deal with userforms e.g
'**MyFormClass
Public Function ReadCaption (argUserForm as UserForm)
MsgBox argUserForm.Caption
End Function

Calling this from a cmd on a userform:
Dim cFormHandler As MyFormClass
cFormHandler.ReadCaption Me

This will never work then because the object does not have such a property.
I can't create routines for every userform used, passing in the speciifc
userform, as in
Public Function ReadCaption (argUserForm as UserForm1)...
Public Function ReadCaption (argUserForm as UserForm2)...etc

NickHK


"Chip Pearson" wrote in message
...

A generic userform object has very few properties. Most
properties are created when the form is created.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"NickHK" wrote in message
.. .

'** In MyClass.cls
Private XLUForm As UserForm
Public Property Set XLUserForm(vData As UserForm)
Set XLUForm = vData
End Property

'**Called from a userform called MyForm
Set MyClass.XLUForm=MyForm

Using the above code in a class in same WB as the passed
UserForm,
vData.Caption always evaluates to "".
But if, whilst in the class, I test ?MyForm.Caption it returns
the correct
value.
Also, properties like vData.Width are no longer "supported",
but
.InsideWidth is.

If I change the declarations to:
Private XLUForm As MyForm
Public Property Set XLUserForm(vData As MyForm)

everything is *normal*.

Anyone explain why ?

NickHK







--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to reference win.caption, when caption changes Paul987[_21_] Excel Programming 3 April 7th 06 05:09 PM
Userform Caption Jason Zischke Excel Programming 2 April 5th 06 08:49 AM
How to format Userform caption? davidm Excel Programming 2 October 3rd 05 07:26 PM
Source of value passed to class object Andrew[_16_] Excel Programming 0 September 2nd 04 01:33 AM
UserForm Caption Soniya Excel Programming 2 October 4th 03 01:53 PM


All times are GMT +1. The time now is 03:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"