Solved

Faster code for loading many pictures

Posted on 1998-08-15
4
150 Views
Last Modified: 2010-04-30
my program has a lot of pictures...i have it programmed so one pic will show and then disappear then the next picture will show and then disappear...but, it takes like forever for the program to load...the code i have goes like this

form_load
image1.visible = true
image2.visible = false
image3.visible = false
(and it goes all the way up to image20)

then i have my timer set to 2400
everytime the timer clicks...
if image1.visible = true then
   image1.visible = false
   image2.visible = true
and this goes on up to image20

is there an easier than typing all of this??
and how can i make the loading process faster???

thanx
0
Comment
Question by:llcoolmel
  • 2
4 Comments
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1429063
You can create an array of picture controls, just give them one name, like Pic1, and set their index properties from 0 to 19
Then u can use loops to hide all of them in a few lines, and show only the one u need
0
 

Author Comment

by:llcoolmel
ID: 1429064
could you give me a sample code for that please???
0
 
LVL 2

Accepted Solution

by:
lmorris earned 100 total points
ID: 1429065
This is were a resource file comes in real handy.

If you don't have the resource file editor from VB's owners area, I suggest you install it. It's free and will make things a lot easier.

Anyway, I've created a resource file with 750K worth of bitmaps in it. I named them 101-125 then placed the following code in a form:

Option Explicit

Private lPicPointer As Long

Private Sub Timer1_Timer()
    If lPicPointer < 101 Then
        lPicPointer = 101
    End If
   
    If lPicPointer > 125 Then
        lPicPointer = 101
    End If
   
    Picture1.Picture = LoadResPicture(lPicPointer, vbResBitmap)
   
    lPicPointer = lPicPointer + 1
End Sub


The compiled program came out to 800K, loaded really fast, and there's not much code to cycle through the pictures.
0
 

Author Comment

by:llcoolmel
ID: 1429066
lmorris, the code works great with bitmaps...but how can i make it work with jpg files???  the format for bitmaps is 0, icons = 1, and cursors = 2....but what is the format for "custom?"
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

708 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