|
-
Nov 17th, 2000, 04:44 PM
#1
Thread Starter
New Member
Perhaps a simple thing, but..How would one go about using a command button to cycle through ( in this case some pictures). I have photos that I want to diplay using a picture box and want to use a command button to click through them. I am able to dispay the first picture easy enough, using picture1.picture.... but how to display the next photo by clicking the command button a second time /third for the 3rd photo etc...etc . VB6
Thanks in advance
rick
-
Nov 17th, 2000, 04:55 PM
#2
Hyperactive Member
Create an Array of strings one element for each picture to display.
load each element with the correct path for the picture
ie PicturePathList[i] = "c:\my_pic1.bmp"
then all you need to do it the following
Code:
Dim StaticCounter As Long
Private Sub cmdNextPic_click()
'' increment the counter
StaticCounter = StaticCounter + 1
'' display the picture
Me.Picture = LoadPicture(PicturePathList[StaticCounter])
'' reset the counter because we are at the last pic?
StaticCounter = StaticCounter Mod Ubound(PicturePathList)
End Sub
you'll probably want to initialize StaticCounter to 0 when you load the form.
-
Nov 17th, 2000, 04:59 PM
#3
You shoudl declare it as Private when using it at module level.
Code:
Private StaticCounter As Long
Also, you can load the file list.
Code:
Picture1.Picture = LoadPicture("MyPhoto" & i)
-
Nov 17th, 2000, 05:16 PM
#4
Hyperactive Member
Yes! you are correct sir. I should have declared it as Private.
-
Nov 17th, 2000, 05:23 PM
#5
Hyperactive Member
Doh... forgot one other thing... initialize the StaticCounter to following instead of 0.
Code:
'' Pre: PicturePathList array has to be initialized
'' before this command.
StaticCounter = LBound(PicturePathList) - 1
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|