Create New Controls at Run Time

Create New Controls at Run Time

This undocumented feature of VB6 lets you create new controls at run time. In previous versions, one had to create a control array at design time in order to be able to add new controls in run time, which would then be the members of the control array. But in VB6, you can do it without a control array.

Paste following code in the Form’s code window:

 Option ExplicitDim WithEvents mctlCommanButton As VB.CommandButtonPrivate Sub Form_Load()    Set mctlCommanButton = Me.Controls.Add(VB.CommandButton,CommandButton1)        mctlCommanButton.Caption = Hi    mctlCommanButton.Left = 10    mctlCommanButton.Top = 10    mctlCommanButton.Visible = TrueEnd SubPrivate Sub mctlCommanButton_Click()    MsgBox HiEnd Sub

Similarly, you can create any control. For example, for a Timer control, use VB.Timer instead of VB.CommandButton in the above code.

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved