Solved

Faster code for loading many pictures

Posted on 1998-08-15
4
152 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…
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…

820 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