I'm wondering if there is a way to declare a user control at runtime. If the user control is compiled into a separate OCX file, you could use the following syntax to declare it:However, assuming that the User Control isn't in a separate OCX file, but it is in the main Project as a User Control, the following lines won't work:VB Code:
' Assume that this user control button is in the file "kControl.ocx" Private WithEvents foCmdEnd As kButton ' ..Further down.. ' Exit/End Program Button Set foCmdEnd = Me.Controls.Add("kControl.kButton", "coCmdEnd")VB Code:
' Error 711: Invalid Class String Set foCmdEnd = foform.Controls.Add("kControl.kButton", "coCmdEnd") ' Error 711: Invalid Class String Set foCmdEnd = foform.Controls.Add("VB.kButton", "coCmdEnd")
Do I have to have it in a separate OCX file if I want to declare it at run time or do I have other options? I can add the object at design time without any hitch, but I can't say the same for adding it at runtime. I don't mind it being in a separate OCX file, but when you have some buggy issues with a user control in a big project file--and not the small one you created to test out the control--it becomes rather annoying to test & correct.![]()




Reply With Quote