Solved

using form1.Controls.Add question

Posted on 2001-07-21
2
164 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 100 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

919 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