Solved

Dynamically Creating Controls at Run time in VB6

Posted on 2002-03-21
6
130 Views
Last Modified: 2011-08-18
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
Comment
Question by:apm825
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:Bahnass
Comment Utility
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
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 200 total points
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 3

Expert Comment

by:Bahnass
Comment Utility
Hi Tim
Am I Fast typist !!!!!
0
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
You were indeed quicker than me with effectively the same answer, do you want some points for it?
0
 
LVL 3

Expert Comment

by:Bahnass
Comment Utility
Dear Tim
    Nice 2 meet U     .....   even if U have my points ;-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now