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

x
?
Solved

Faster code for loading many pictures

Posted on 1998-08-15
4
Medium Priority
?
156 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 400 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…
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…
Suggested Courses

688 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