Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default UserForm Variable

Excel 2002, SP3

Based on the research I have done thus far, I don't like what I see as it
breaks away from good programming practices and it also relies on late
binding rather than early binding.

When declaring userform variables, it must be assigned to the "Object" type
to be able to use a few different things like the Show method. While using
"Object" is slightly better, it's still almost as bad as using "Variant"
cause it doesn't specify the "TYPE" of object.

Why does the VBA UserForm Object not match up to the UserForm that's created
within Excel VBA. If it's cause the actual UserForm is only for Excel, then
why does the Excel codes not have a UserForm object that can be used
programmatically?

--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default UserForm Variable

When declaring userform variables, it must be assigned to the "Object"
type


If you want to assign some unknown userform to an Object variable, then yes,
you will need to declare as variant or as object. Alternatively, if you know
in advance which userform you want to assign then do
Dim uf1 as Userform1

You'd need to do exactly the same if you want to assign an ordinary class
module to a variable. As Object or As Class1 but not As Class (a userform is
a class module, albeit a custom one provided by the MSForms library)

You could do
dim uf As Userform
set uf = [new] Userform1

but be careful as 'uf' will not be assigned to the representation of the
form you expect, it will have virtually none of the methods that only become
available once the form has become a member of your project, or rather it
may have apparently similar methods but to different aspects of the object.
IOW, there's a difference between the form as a member of MSForms (uf) and
as a member of your project (uf1).

Regards,
Peter T


"Ronald R. Dodge, Jr." wrote in message
...
Excel 2002, SP3

Based on the research I have done thus far, I don't like what I see as it
breaks away from good programming practices and it also relies on late
binding rather than early binding.

When declaring userform variables, it must be assigned to the "Object"
type to be able to use a few different things like the Show method. While
using "Object" is slightly better, it's still almost as bad as using
"Variant" cause it doesn't specify the "TYPE" of object.

Why does the VBA UserForm Object not match up to the UserForm that's
created within Excel VBA. If it's cause the actual UserForm is only for
Excel, then why does the Excel codes not have a UserForm object that can
be used programmatically?

--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default UserForm Variable

I guess I will just have to live with using this Object bit as I'm not about
to DE-modulate my code just to satisfy the specific declaration aspect of
good programming practices. Not only that, but at least the Object bit is
still allowed in the .NET environment, should MS decide to move VBA that
way, where as Variant isn't allowed in the .NET environment.

As for the Userform being a class module, I thought about that just like the
Form object within Access is also a class module.

--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"Peter T" <peter_t@discussions wrote in message
...
When declaring userform variables, it must be assigned to the "Object"
type


If you want to assign some unknown userform to an Object variable, then
yes, you will need to declare as variant or as object. Alternatively, if
you know in advance which userform you want to assign then do
Dim uf1 as Userform1

You'd need to do exactly the same if you want to assign an ordinary class
module to a variable. As Object or As Class1 but not As Class (a userform
is a class module, albeit a custom one provided by the MSForms library)

You could do
dim uf As Userform
set uf = [new] Userform1

but be careful as 'uf' will not be assigned to the representation of the
form you expect, it will have virtually none of the methods that only
become available once the form has become a member of your project, or
rather it may have apparently similar methods but to different aspects of
the object. IOW, there's a difference between the form as a member of
MSForms (uf) and as a member of your project (uf1).

Regards,
Peter T


"Ronald R. Dodge, Jr." wrote in message
...
Excel 2002, SP3

Based on the research I have done thus far, I don't like what I see as it
breaks away from good programming practices and it also relies on late
binding rather than early binding.

When declaring userform variables, it must be assigned to the "Object"
type to be able to use a few different things like the Show method.
While using "Object" is slightly better, it's still almost as bad as
using "Variant" cause it doesn't specify the "TYPE" of object.

Why does the VBA UserForm Object not match up to the UserForm that's
created within Excel VBA. If it's cause the actual UserForm is only for
Excel, then why does the Excel codes not have a UserForm object that can
be used programmatically?

--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000





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
Set Userform As A Variable Roger Excel Programming 0 February 20th 09 10:59 AM
variable available after userform filo666 Excel Programming 2 March 18th 08 10:06 AM
Userform and variable Jeff Excel Discussion (Misc queries) 1 March 16th 07 03:14 PM
userform and variable Gary Keramidas Excel Programming 11 December 6th 06 05:34 PM
VBA Variable as userform [email protected] Excel Programming 3 April 13th 06 08:32 PM


All times are GMT +1. The time now is 05:12 PM.

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

About Us

"It's about Microsoft Excel"