Click to See Complete Forum and Search --> : file scrolling
kpooi
Mar 2nd, 2002, 10:27 PM
Does anyone know how to retrieve the next file from a directory with a click of a button or something ?
Lets say i opened a picture from a directory. And i want to view the next picture with just a click of a button instead of opening the file.
If anyone know any codes who can do this please help me out.
-----------------------------------------------------------------------------------
Vb rules
ndvck
Mar 4th, 2002, 12:04 PM
Hi
U can try this code.
start a Standard EXE project. To the form add 2 buttons and give names "Start" and "Next".
Add a Text box.
Paste the following code
******************
Option Explicit
Dim mbBreak As Boolean
Dim mbNext As Boolean
Private Sub Command1_Click()
On Error GoTo ErrorHandler
Dim lsRootDir As String
Dim lsFileName As String
lsRootDir = "c:\"
lsFileName = Dir(lsRootDir)
Text1.Text = lsFileName
mbNext = False
Do While lsFileName <> "" And Not mbBreak
If (mbNext) Then
lsFileName = Dir()
Text1.Text = lsFileName
mbNext = False
Else
DoEvents
End If
Loop
Exit Sub
ErrorHandler:
MsgBox Err.Description
End Sub
Private Sub Command2_Click()
mbNext = True
End Sub
Private Sub Form_Load()
mbBreak = False
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
mbBreak = True
End Sub
******************
It can be done more cleanly using APIs or File Control. Hope it will work for u.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.