This was supposed to be for VB.Net but then I thought, with how much tools available at VB.Net, anybody can really do an image slider in VB.Net easily so I thought to myself, why not try to do this in VB6?
The concept I challenged myself with was simple: The form would display the image and upon clicking the image, the next one will be shown. The image source would be a folder so we can easily switch or point it to a different folder. That's the basic challenge. If you want, you can do advanced where you can search within subdirectories or perform validations, etc.
So here's what I came up with...a very basic, simple Image or Picture Slider. Enjoy!
For this project, we'll need 4 modular variables:
You might be asking, "what controls do I place on the form?"
And the answer is "none". We just need an image box which we will create dynamically --- as a bonus tutorial :)
See the "withevents" variable there? That will be our dynamic image box
Now we go to the meat of the project where we collect the list of images and place them inside a collection. Later we'll use the collection to get the image path.
Note that we're not storing the actual image in the collection.
This is okay if you'll be storing only small numbers like maybe 20 images and small sizes. If you store large images, you'd probably run out of memory. That's why we only store the locations (or pointers) of the image files.
Now that we have the code for collecting the list of images, we need the subroutine or method that will display the file into our dynamic image box:
Then as part of the requirement/challenge, clicking the image should "slide" to the next image on the list. Here's the code for that:
Lastly I made a routine to make the image box resize along with the form (this is optional):
So, give this a try and tell me how it went and where do you think you can use this?