Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 141
  • Last Modified:

Dynamically Creating Controls at Run time in VB6

How do you dynamically create Controls at Run time WIITHOUT using a control array. I want the control not to be on the form at design time...then create it dynanically at run time.

Thanks!
0
apm825
Asked:
apm825
  • 3
  • 2
1 Solution
 
BahnassCommented:
from msdn


Private Sub Form_Load()
   Form1.Controls.Add "VB.CommandButton", "cmdObj1", Frame1
   With Form1!cmdObj1
      .Visible = True
      .Width = 2000
      .Caption = "Dynamic Button"
   End With
End Sub

0
 
Éric MoreauSenior .Net ConsultantCommented:
0
 
TimCotteeCommented:
Use the following syntax:

Dim Ctrl As Control
Set Ctrl = Me.Controls.Add("VB.Textbox","MyTextbox")
With Ctrl
  .Left = 1000
  .Width = 1000
  .Height = 500
  .Top = 500
  .Visible = True
  .Text = "Hello There
End With
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
BahnassCommented:
Hi Tim
Am I Fast typist !!!!!
0
 
TimCotteeCommented:
You were indeed quicker than me with effectively the same answer, do you want some points for it?
0
 
BahnassCommented:
Dear Tim
    Nice 2 meet U     .....   even if U have my points ;-)
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now