Results 1 to 5 of 5

Thread: Cycle thruoght pics using cmd button

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    1

    Cool

    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

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    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.
    -Shickadance

  3. #3
    Guest
    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)

  4. #4
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    Yes! you are correct sir. I should have declared it as Private.
    -Shickadance

  5. #5
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    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
    -Shickadance

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width