ImageLooper Control
I am working on a VB tutorial, and at the same time trying to create my first control called ImageLooper. This is pretty straightforward, a control box with a picturebox1 inside, a left arrow button and a right arrow button (button1 and button1 respectively). The idea is, with each click in either direction, the next or previous in line image will display, depending on which arrow is clicked.
Each button works individually ok, but when I switch from the left arrow button to the right or visa versa, instead of going to the next image down or up, on the first click, it takes one step in the opposite direction, displays that (wrong) image, then, with subsequent clicks, starts moving through the images correctly. The language is below:
PrivateSub Button2_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles Button2.ClickPictureBox1.Image = System.Drawing.Image.FromFile _
(
"E:\vb05sbs\chap07\face0" & Counter &".ico")Counter += 1
If Counter = 5Then Counter = 1EndSubPrivateSub Button1_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles Button1.ClickPictureBox1.Image = System.Drawing.Image.FromFile _
(
"E:\vb05sbs\chap07\face0" & Counter &".ico")Counter -= 1
If Counter = 0Then Counter = 4EndSubThe referenced "face0" images are happy face images from sad to very happy and are named face01, face02, face03, face04. they are provided with the tutorial to give you something to work with, but it could be anything like that which can be incremented in number.
There is this functionality in the winfax viewer, where you can right click open that image in the viewer and from that initial image you can then click a right arrow and loop through everything in the folder. If it reaches the end it just starts over, which this code does. But that is what I am trying to achieve with making this control.
The other questions on this would be, what if you don't want to name a specific folder or file, but have it be a folder or starting file selected from a common dialog, or a selected filename from a listbox list?
Thanks in advance...

