Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

using form1.Controls.Add question

Posted on 2001-07-21
2
Medium Priority
?
171 Views
Last Modified: 2008-02-01
I want to use the frmDroppers.Controls.Add to add a number of picture boxes (50 or more) into a program during runtime, i want to be able to control each picturebox, how can i make the added control an array item? or whats the best way to add the controls?

curently i've been using:

   form1.Controls.Add "VB.Picturebox", "NewPic", PicSpace
   With form1!NewPic
      .Picture = pic1.Picture
      .AutoSize = 1
      .Left = 1925
      .BorderStyle = 0
      .Visible = True
   End With

(PicSpace is the name of the picturebox the picture is being created in and pic1 contains the picture to be placed into the new control.

Does this make sence?

thanks in advance
0
Comment
Question by:xizor
2 Comments
 
LVL 8

Accepted Solution

by:
glass_cookie earned 400 total points
ID: 6304936
How about trying this:

Create a picture box with index 0.

Then, add this code:

For i = 1 To 50 'Or whatever number you want
Load Picture(i)
Picture(i).Picture = pic1.Picture 'or maybe an array of pictures
Picture(i).AutoSize = 1
Picture(i).Left = 1925
Picture(i).BorderStyle = 0
Picture(i).Visible = True
Next i

That's it!

glass cookie : )
0
 

Expert Comment

by:BlackShark
ID: 6304961
hello xizor,

sorry i'm a newbie in vb and not sure about the best way..

add in design:
PicSpace.Index=0

add in your code:
Load PicSpace(PicSpace.Count) 'control with next index
With PicSpace(PicSpace.Count-1) 'use new control
     .Picture = pic1.Picture
     .AutoSize = 1
     .Left = 1925
     .BorderStyle = 0
     .Visible = True
End With
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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

783 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