Solved

creating a control array at run time

Posted on 2004-08-26
3
153 Views
Last Modified: 2010-05-02
hi. how can i make a control array of 10 image controls at run time.
imean i wish to create 10 image controls at run time and they are named such that they are accessible using array notation like
img(0), img(1)...etc.
Thanks.
0
Comment
Question by:astudent
3 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 125 total points
ID: 11909932
You can't create a control array at runtime.

The way around this is to place one image control on your form with its index property set to 0.  Then when you need another control added to the array you can use the Load statement:

    Load Image1(Image1.Count) ' add one more to the control array

Regards,

Idle_Mind
0
 
LVL 10

Expert Comment

by:anv
ID: 11910612
u cannot create a control array at run time but u can create a collection at run time...

u need to have atleast one control with index property set to 0 in design time , to create a control array at runtime
0
 
LVL 1

Expert Comment

by:Arnee_Senthil
ID: 11912121
Here u need to place atleast one control as said by ANV and have to change the index prop to 0

for ex.,

place a command btn in a form and change its index property to 0 and run the code given below

it will create 10 btns


'==============================================
' To create 10 object start from 1 to 9 ( 1 obj placed already in the form)
'==============================================
    For i = 1 To 9        
'==============================================
'  creates  a obj in the form
'==============================================
       Load Command(i)                                                      
'==============================================
' by default visible is false for runtime created object so make it visible
'==============================================
       Command(i).Visible = True                                
'==============================================
'Moves the object to some place, by default all objects created at the same place. with out this all created objects stacked togethere
'==============================================
       Command(i).Top = Command(i).Top + i * 100
    Next


Cheers,
Arne.,
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Access Search and Replace Using VBA 6 80
Sending a email via excel using vba 6 96
Automatic Email Reminder 4 56
VBA - If Bookmark = "XXBOOKMARKXX" then 15 40
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

808 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