Solved

Faster code for loading many pictures

Posted on 1998-08-15
4
153 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
[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
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

751 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