View Single Post
  #2 (permalink)  
Old 06-10-2007, 05:19 PM
Deep Thought
Posts: n/a
assuming that you're using VB6:

- put all the pictures in a sub-folder of the folder where your program is installed, let's say this pictures subfolder is called "photos"

--------------------------------

- put a FileListBox (named File1) object on your form (it would be better to use the FileSystemObject object but I won't get into that, as it's a little more complicated),
so, on the form's Load Event write this:


Dim picturesFolder As String

'assuming that all your pictures are JPG
'if you have different types of pictures don't use the next line but make sure to put only pictures in that folder

File1.Pattern = "*.jpg"

'set the pictures folder

picturesFolder = App.Path & "\photos\"

'if the pictures folder exists and has files in it

If Dir(picturesFolder) <> "" Then
File1.Path = picturesFolder
Else
MsgBox "can't find pictures in " & picturesFolder
End If

'hide the file list, as we are using it only to get the file names

File1.Visible = False

'set the current index of the displayed file to 0 (the first file in the list)

crtIdx = 0

'display the first picture
If (File1.ListCount > 0) Then
Picture1.Picture = LoadPicture(File1.Path & "\" & File1.List(crtIdx))
end if

--------

- put a pictureBox object on your form (named Picture1)

--------

- make a private variable for the form to hold the current index of the displayed file (select General, then Declarations from the code window) and write

private crtIdx as Integer


--------

- on the button that you use to display the next picture (on the OnClick event) write this

' go to the next picture

If crtIdx < File1.ListCount - 1 Then
crtIdx = crtIdx + 1
Else
crtIdx = 0
End If

'display that picture
If (File1.ListCount > 0) Then
Picture1.Picture = LoadPicture(File1.Path & "\" & File1.List(crtIdx))
end if


if you're using VB .NET email me, I'll give you an example for that as well

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!