Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Set Userform As A Variable | Excel Programming | |||
variable available after userform | Excel Programming | |||
Userform and variable | Excel Discussion (Misc queries) | |||
userform and variable | Excel Programming | |||
VBA Variable as userform | Excel Programming |