Solved

using form1.Controls.Add question

Posted on 2001-07-21
2
163 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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…

762 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

7 Experts available now in Live!

Get 1:1 Help Now