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:
VB Code:
  1. ' Assume that this user control button is in the file "kControl.ocx"
  2. Private WithEvents foCmdEnd          As kButton
  3.  
  4. ' ..Further down..
  5.  
  6. ' Exit/End Program Button
  7. Set foCmdEnd = Me.Controls.Add("kControl.kButton", "coCmdEnd")
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:
  1. ' Error 711:  Invalid Class String
  2. Set foCmdEnd = foform.Controls.Add("kControl.kButton", "coCmdEnd")
  3.  
  4. ' Error 711:  Invalid Class String
  5. 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.