?
Solved

Very Easy Newbie VB QN

Posted on 2003-03-24
3
Medium Priority
?
135 Views
Last Modified: 2010-05-01
How do you create a control at runtime?  Say I want to create an array of combo boxes at runtime,  

Set DataComboMatrix(i, j) = ???
0
Comment
Question by:chaplt01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 140 total points
ID: 8193810
Hello chaplt01,

you could take a look at this
http://www.vbexplorer.com/VBExplorer/vb_feature/april2000/april2000.asp

HAGD:O)Bruintje
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 8193951
You can only create an array at design time. You can do this by setting the index of a control to a number. So that you then might have a control such as Combo1(0).
You can add other members at run time with the load statement:

Load Combo1(1)
Load Combo1(2)

You can't create an array with more than one dimension, as in your example, though.
0
 
LVL 1

Expert Comment

by:FunkyMeister
ID: 8199854
You can create any client object at run time easily using API calls.

Though this can be risky if you're not familiar with API calls, a good suggestion is to search for "API" and "DrawFrameControl"

Declare Function DrawFrameControl Lib "user32" Alias "DrawFrameControl" (ByVal hDC As Long, lpRect As RECT, ByVal un1 As Long, ByVal un2 As Long) As Long

A good place to look is AllAPI.net, they have a program (http://www.allapi.net/agnet/apiguide.shtml) there that'll let you scan and read up on these functions.  With the hDC of your window, you can ADD many types of controls to your window at runtime.  Just remember though, a good programming technique is to remove them before you're done (although a window will remove all clients inside of it at closure, it's always best to do your own housekeeping).

API calls aren't for the faint of heart, but having a program that keeps all the definations and what they mean (with examples), gives you a lot to go on.
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Suggested Courses
Course of the Month9 days, 6 hours left to enroll

764 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