Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Help about :    Load picture1(index) ..........

Posted on 2004-03-21
7
Medium Priority
?
343 Views
Last Modified: 2006-11-17
Hello Experts ,
      i have taken a array of Picture Box (Picture1(0))

i load remaining 10 picture boxes as
for i=1 to 10
    load (picture1(i))
    picture1(i).visible=true
next i


Now if i removed control array number 4 as :-
       unload picture1(4)

and if i want to add new image to the existing 10 picture controls , when loop comes at 4 th position , it gives error

how to avoid this error message ?

is it possible to lift all remaining control array elements ?

Waiting for responce

Milind
0
Comment
Question by:asdddd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 15

Expert Comment

by:unknown_routine
ID: 10644883
you unload picture1(4)

so picture1(4)  does not exist and it give you an error.

lift all remaining? what exactly you mean by tha
0
 
LVL 6

Expert Comment

by:___XXX_X_XXX___
ID: 10645003
I think, by "lift", he wants to move Picture1(5) to Picture1(4), Picture1(6) to Picture1(5).

But Picture1(4) doesn't exist after you unload it. So you must keep in mind that Picture1(4) is not usable anymore.
0
 
LVL 4

Expert Comment

by:learning_t0_pr0gram
ID: 10645231
try..

For x = 1 to 10
if x = 4 then x = x + 1
' rest of the code
Next
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 28

Expert Comment

by:Ark
ID: 10645616
For Each pic In Picture1
   Debug.print pic.Index
 ' ....
Next
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 300 total points
ID: 10649480
You have two basic options:

1) Don't unload controls from the array.  Set their visibility to True or False instead.

2) Use Error trapping to detect the missing control item and load it back up like this:

Private Sub Command1_Click()
    On Error GoTo loadItBackUp
   
    Dim i As Integer
   
    For i = 1 To 10
        Picture1(i).Tag = "something" ' attempt to access each item in array
    Next i
    Exit Sub
   
loadItBackUp:
    Select Case Err.Number
        Case 340 ' Control array element doesn't exist
            Load Picture1(i)
            Resume
           
        Case Else
            MsgBox Err.Description, , "Error " & Err.Number
    End Select
End Sub

Idle_Mind
0
 

Author Comment

by:asdddd
ID: 10669773
Hello Idle_Mind ,
    u r code (No 1) is the suitable option for my project. It is working properly by simply making it visible=false . But can u please answer my question ?
   is there any memory problems when control array goes on increasing .
   i m going to accept u r answer.


Thanks
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 10670536
Well...you can continue to load up as many pictureboxes as will fit into memory.

It would really depend on what you are doing with the pictureboxes.  Someone may have a better solution if they know your end goal.

Idle_Mind
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

670 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