Scroll through pictures in a folder

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi i want to make a command button which scrolls through several pictures in
a folder. The Folder address will be made up of several fields in the form.
txtCoreAddress - will contain "C:\Documents\Pictures\"
txtSubFolder - will contain the next folder name "00001-00001"
The images within each folder are then number anything between 1 and 5,
making the address for one photo
C:\Documents\Pictures\00001-00001\3.JPG
I have no problem taking the above complete address and getting the image to
show, but have no idea how to make it scroll through only the pictures in
that folder.
Please advise
Mike
 
So store the path as 3 separate text fields then concatenate them as
necessary:

Drive:
C:\Documents\Pictures\

Path:
00001-00001\

FileName:
3.JPG

Then use:

Me.ImageCtl.Picture = txtDrive & txtPath & txtFileName
 
Dim strFolder As String
Dim strFile As String

strFolder = "C:\Documents\Pictures\00001-00001\"
strFile = Dir(strFolder & "*.jpg")
Do While Len(strFile) > 0
' at this point, strFolder & strFile should provide the complete
' path to a picture.
' Do whatever you want with it...

' This line will set strFile to point to another picture,
' or to a zero-length string if you've seen them all
strFile = Dir()
Loop
 
Back
Top