Results 1 to 11 of 11
  1. #1
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    List a list of documents (VB6)

    This is a little idea floating around in my head at the moment and there has been no development apart from the comments on this page:

    I want to be able to open a form up and then select a drive and then a folder. This folder will contain a set of Word documents that I wish to do "something" to. I want a multi-select list box to populate with the Word docs in that folder.

    I can do the directorty search bit but just a little <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15> with the population of the multi-select list box any good resources out there?

    Ultimately I will have to of these lists side by side showing the same documents like below
    Jerry

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: List a list of documents (VB6)

    Say that you have a string variable strPath that holds the path of the folder selected by the user. You can use the good old Dir function to loop through the Word documents in the folder and use the AddItem method of the list box to add the file names:
    <code>
    Dim strFile As String
    Dim strPath As String

    ' code to set strPath goes here
    ...

    strFile = Dir(strPath & "*.doc")
    Do While Not strFile = ""
    Me.lstFiles.AddItem strFile
    strFile = Dir
    Loop
    </code>
    Note: the list box will hold only the file names, without the path. If you later want to do something with them, remember to concatenate them with strPath & "" to get the full path.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: List a list of documents (VB6)

    Excellent

    Now I was looking to create an array as I want to do some "stuff" to loop the list other list box


    Would this work (remember this is air code so it will need to be tweaked by me)

    Do While Not strFile = ""
    i=i+1
    strListItem(i)=strFile
    Me.lstFiles.AddItem strFile
    strFile = Dir
    Loop

    Doing this I can then assign an array value (strListItem) and I can then do my manipulation and "stuff" in the code
    Jerry

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: List a list of documents (VB6)

    You would either have to declare the array with a fixed sufficiently large number of items, e.g.
    <code>
    Dim strListItem(1 to 100) As String
    </code>
    or declare it dynamically and resize it as you go:
    <code>
    Dim strListItem() As String

    ...

    i = i + 1
    ReDim Preserve strListItem(1 to i)
    strListItem(i) = strFile

    ...</code>

  5. #5
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: List a list of documents (VB6)

    Briiliant, I am on the right path now. The reason I am assigning the value is because I am just putting together a very basic anti-plagiarism application that we have discussed in various threads recently. I was looking to create a Bubble sort application that can run through each document. <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Jerry

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: List a list of documents (VB6)

    In my experience, Dir returns files sorted in alphabetic order.

  7. #7
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: List a list of documents (VB6)

    Jezza

    Just perusing this thread, it got me wondering exactly what you were hoping to do with each document reference. If it's detailed or involved, maybe it's worth writing a DocRef class, then creating DocRef objects from folders and adding to a collection for further scenarios. Not worth it if it's something simple, but ultimately cleaner than looping and maintaining arrays. Just a thought(s).

    Alan

  8. #8
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: List a list of documents (VB6)

    I shall bear that in mind Alan. This is a little (big) project in the infancy stage of concept and I was thinking about the logical steps a person does when checking/comparing documents.

    Say you have three documents A, B and C and you want to compare them you would do the following:

    Get A compare to B and C
    Get B compare to A and C
    Get C compare to A and B

    By providing two lists I was going to give each list item a "reference", obviously there is no need to compare a document against itself hence why I wanted a reference so that the code would look like this:

    Click on a document in list1 and then something like this air code


    If List1docref(i) = List2docref(i) then

    Do Nothing

    Else

    Do Something

    End if


    Do you think that is reasonable? I will only have small batches of 50 documents
    Jerry

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: List a list of documents (VB6)

    I assume that comparing A to C is the same as comparing C to A. With 50 documents, you'd still have to do (50 * 49) / 2 = 1225 pairwise comparisons!

    The loop structure would look like

    Dim i As Integer
    Dim j As Integer

    For i = 1 To 49
    For j = i+1 To 50
    Compare document(i) to document(j)
    Next j
    Next i

    (You need only one list for this)

  10. #10
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: List a list of documents (VB6)

    Now you can see why I want to automate the process , just to take away some of the repetitive clicking. I see your point exactly and can't argue your proposal apart from the fact there will have to be a human step in the process where they physically check the document so it will be a step process. Thanks for your input.
    Jerry

  11. #11
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: List a list of documents (VB6)

    Jezza

    Will these be Word docs? If so, the checker might be able to use an existing or custom property to record/ update the checked status. Even if not, something like HobComment XP Shell Extension v1.00 beta might be of some use?

    Alan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •