|
-
Nov 20th, 2000, 07:17 PM
#1
Thread Starter
Junior Member
Is there a way to get all the files from a specific folder(preferably image files), and then load them into an array? (Its for a screen saver that scrolls through all the pictures in a folder). Thanks
-
Nov 20th, 2000, 07:25 PM
#2
Addicted Member
Check the Dir function. I think if you use it in a loop, you can get the files into an array.
-
Nov 20th, 2000, 07:33 PM
#3
Hyperactive Member
Use a FileListBox, setting the Path property to where your folder lives, setting the Pattern property to *.img,*.ico for img and ico files (or however you wanna do that), then ReDim a string array.
Dim MyArray() As String
filMyFiles.Path = "C:\MyFolder"
filMyFiles.Pattern="*.img"
Redim MyArray(filMyFiles.ListCount)
For i = 1 to filMyFiles.ListCount ' maybe 0 is start index?
...
I forgot if the lowest index of a filelistbox is 0 or 1.
You can also use the Dir function:
sFile = Dir("C:\MyFolder", vbDirectory)
Do While sFile <> ""
If instr(1,sFile,".img")<>0 Then
' add it to your array
' problem here is that you might have to
' ReDim Preserve along the way
End If
sFile = Dir
Loop
-
Nov 20th, 2000, 08:22 PM
#4
_______
<?>
Code:
Option Explicit
Private Sub Form_Load()
Dim myArr()
Dim stFile As String, stDir As String
Dim iCount As Integer
'access all files within the C:\Windows Directory
stDir = "C:\Windows\"
'here I designate .gif but you can change it to the filetype you use
stFile = Dir$(stDir & "*.gif")
Do While stFile <> ""
ReDim Preserve myArr(iCount)
myArr(iCount) = stDir & "/" & stFile
iCount = iCount + 1
stFile = Dir
Loop
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|