Getting file info using a file list box and putting in an array 
Author Message
 Getting file info using a file list box and putting in an array

I am using a drive list box, a directory list box and a file list box.  I
can get the number of files in the file list box by using
filFile.ListCount   I can even get the filename using     filFile.FileName
but how can I store all of the files using a for loop?  How can I put this
information into some sort of array in order to call up certain files?

    For intTemp = 0 To 2
        strFileName(intTemp) = filFile.FileName
    Next intTemp

Thanks for any ideas
Kevin



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting file info using a file list box and putting in an array
  Dim strFileName() As String
  ReDim strFileName(filFile.ListCount - 1)
  For x = 0 To filFile.ListCount - 1
    strFileName(x) = filFile.List(x)
  Next

Rick


Quote:
> I am using a drive list box, a directory list box and a file list box.  I
> can get the number of files in the file list box by using
> filFile.ListCount   I can even get the filename using     filFile.FileName
> but how can I store all of the files using a for loop?  How can I put this
> information into some sort of array in order to call up certain files?

>     For intTemp = 0 To 2
>         strFileName(intTemp) = filFile.FileName
>     Next intTemp

> Thanks for any ideas
> Kevin



Sat, 15 Feb 2003 12:47:12 GMT  
 Getting file info using a file list box and putting in an array
Hmm, well it didn't work quite like I had hoped.  Your way worked great, but
it was not how I thought I would be able to do it.  I am trying to make
thumbnails and I have an image box array set up, but I can't seem to get it
to advance to the next file and load it into the according image box.
How can I do this:    filFile =  the next filFile in directory

in order that I can use a image box array like this:

Private Sub Form_Load()
    Dim X As Integer
    Dim imgPicture() As PictureBox    ' I have also tried this as Image if
that matters
    For X = 0 To filFile.ListCount - 1
        imgPicture(X).Picture = LoadPicture(filFile)  ' This is where I am
having the problem
    Next X
End Sub

I have many image boxes on my form going from imgPicture(0) to
imgPicture(7).  When I try to run the app I get a runtime error saying that
subscript is out of range.  I can't seem to get the filFile to advance on to
the next file.
Any ideas on this one?
Thanks for your help again,
Kevin



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting file info using a file list box and putting in an array
filFile doesn't increment through the FileListBox names and even if you
provided the List(x) portion to do that, it wouldn't contain the full path
to your files -- only their names. Try changing your code to this

    Dim X As Integer
    Dim imgPicture() As PictureBox
    For X = 0 To filFile.ListCount - 1
        imgPicture(X).Picture = LoadPicture(Dir1.Path & "\" &
filFile.List(x))
    Next X

You didn't post the name you are using for the DirectoryListBox so I used
Dir1 for this example. Change that to the name you are actually using.

Rick


Quote:
> Hmm, well it didn't work quite like I had hoped.  Your way worked great,
but
> it was not how I thought I would be able to do it.  I am trying to make
> thumbnails and I have an image box array set up, but I can't seem to get
it
> to advance to the next file and load it into the according image box.
> How can I do this:    filFile =  the next filFile in directory

> in order that I can use a image box array like this:

> Private Sub Form_Load()
>     Dim X As Integer
>     Dim imgPicture() As PictureBox    ' I have also tried this as Image if
> that matters
>     For X = 0 To filFile.ListCount - 1
>         imgPicture(X).Picture = LoadPicture(filFile)  ' This is where I am
> having the problem
>     Next X
> End Sub

> I have many image boxes on my form going from imgPicture(0) to
> imgPicture(7).  When I try to run the app I get a runtime error saying
that
> subscript is out of range.  I can't seem to get the filFile to advance on
to
> the next file.
> Any ideas on this one?
> Thanks for your help again,
> Kevin



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting file info using a file list box and putting in an array
I got some more errors but figured it out.  I had already made an array on
my form by copying and pasting one image box until I had about 8 of them.
Then I was starting the array again by using my   Dim imgPicture() As
PictureBox   line in my code.  Your piece of code worked great and I greatly
appreciate your help once again.
I was wondering.....I can find out how many files are in a directory by
using the file count property, but is there an easy way to have code to
place that many "thumbnails" in my app window.  I know I could copy and
paste as many as I would need and then hide the ones that are not used, but
I would like to be able to have up to 500 thumbnails or so, and that could
take me awhile.
Thanks again for your help,
Kevin


Quote:
> filFile doesn't increment through the FileListBox names and even if you
> provided the List(x) portion to do that, it wouldn't contain the full path
> to your files -- only their names. Try changing your code to this

>     Dim X As Integer
>     Dim imgPicture() As PictureBox
>     For X = 0 To filFile.ListCount - 1
>         imgPicture(X).Picture = LoadPicture(Dir1.Path & "\" &
> filFile.List(x))
>     Next X

> You didn't post the name you are using for the DirectoryListBox so I used
> Dir1 for this example. Change that to the name you are actually using.



Wed, 18 Jun 1902 08:00:00 GMT  
 Getting file info using a file list box and putting in an array
I am trying to build an array of imageboxes in my coding.  I want them to
then be displayed on my app form.  In each imagebox is going to be a
different image. I am basically making a thumbnail function to my program.
I can tell how many images are in the directory, so I need to use this
information to make that many imageboxes.  In this trial coding I am just
trying to make the imageboxes go in a straight line to the right one after
another, but I keep getting an error:   Run-time error '91': Object variable
or With block variable not set
This procedure is called by other procedures:

Public Sub Thumbnails()
    Dim imgPicture(10) As PictureBox
    Dim X As Integer
    For X = 0 To filFile.ListCount - 1
        imgPicture(X).Left = 2500 + 2500 * X
        imgPicture(X).Height = 3000
        imgPicture(X).Width = 3000
        imgPicture(X).Top = 800
        imgPicture(X).Picture = LoadPicture(dirDirect.Path &
filFile.List(X))
    Next X
End Sub

I can't seem to get this one figured out either :)
If I can get this one to work, them I need to try to figure out scroll bars
in order that the user can move over on the form and access the other
thumbnails.  I have never been able to figure out the whole scroll bar thing
either.
Thanks again for your help,
Kevin


Quote:
> filFile doesn't increment through the FileListBox names and even if you
> provided the List(x) portion to do that, it wouldn't contain the full path
> to your files -- only their names. Try changing your code to this

>     Dim X As Integer
>     Dim imgPicture() As PictureBox
>     For X = 0 To filFile.ListCount - 1
>         imgPicture(X).Picture = LoadPicture(Dir1.Path & "\" &
> filFile.List(x))
>     Next X

> You didn't post the name you are using for the DirectoryListBox so I used
> Dir1 for this example. Change that to the name you are actually using.

> Rick



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. including file info in file list box

2. Getting the length of selected files in a File List Box (sum in bytes)

3. Getting selected files (file list box)

4. Getting selected files (file list box)

5. MULTI FILE SELECTION USING FILE LIST BOX?

6. Reading file name from text box and/or File List Box

7. Please help,trying to put selected items from array into list box

8. please help,trying to put selected items from array into list box

9. Help wanted with file list boxes and list boxes

10. newbie q: how to get list of files into array w/o dialog box

11. Getting a detailed directory listing using Internet transfer control, file sizes

12. help switching file names or getting list of files in a dir

 

 
Powered by phpBB® Forum Software