Solved

Faster code for loading many pictures

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

930 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