Sub getallfile(ByVal mydir As String, ByRef x() As String)
Dim fname As String, i As Integer
If Right(mydir, 1) <> "\" Then mydir = mydir & "\"
fname = Dir(mydir & "\*.jpg")
i = 1
Do While fname <> ""
ReDim Preserve x(1 To i)
x(i) = mydir & fname
i = i + 1
fname = Dir
Loop
End Sub
Private Sub Command1_Click()
If index = UBound(alljpgfile) Then
index = 1
Else
index = index + 1
End If
Image1.Picture = LoadPicture(alljpgfile(index))
End Sub
Private Sub Command2_Click()
If index = 1 Then
index = UBound(alljpgfile)
Else
index = index - 1
End If
Image1.Picture = LoadPicture(alljpgfile(index))
End Sub
Private Sub Form_Load()
Command1.Caption = "prev"
Command2.Caption = "next"
index = 1
Image1.Stretch = True
getallfile "C:\Documents and Settings\hsy\My Documents\My Pictures", alljpgfile
Image1.Picture = LoadPicture(alljpgfile(index))
End Sub
Dim idx As Integer
Private Sub Command1_Click()
If idx >= 1 Then
idx = idx - 1
Image1.Picture = LoadPicture(File1.Path & "\" & File1.List(idx))
End If
End Sub
Private Sub Command2_Click()
If idx < File1.ListCount - 2 Then
idx = idx + 1
Image1.Picture = LoadPicture(File1.Path & "\" & File1.List(idx))
End If
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
File1.Refresh
On Error GoTo chli:
idx = 0
Image1.Picture = LoadPicture(File1.Path & "\" & File1.List(idx))
chli:
Exit Sub
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
Dir1.Refresh
End Sub