Solved

using form1.Controls.Add question

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Suggested Solutions

Title # Comments Views Activity
Validating VB6 Function 19 65
Windows Script Host failed (Access is denied.) error 6 215
Set email body to html using vbscript 6 49
Formula problem with Excel attachment 6 38
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…

792 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