?
Solved

Load items in Listbox.

Posted on 2007-07-25
11
Medium Priority
?
385 Views
Last Modified: 2007-12-19
I know how to open a text file and load the contents into a listbox. How can I select a range of text files and load them into the listbox?
0
Comment
Question by:Takamine334
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 15

Expert Comment

by:SnowFlake
ID: 19572006
if you tell us how you plan to do the first we might be able to help you extend to the later.
are you talking about client side? server side? using what scripting language ?
Snowflake
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 19572008
What programming language ?
0
 

Author Comment

by:Takamine334
ID: 19572569
Sorry, I thought I put this in the VB6 section.

It's in VB6
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Takamine334
ID: 19572574
Public Sub mnuOpen_Click()
With CommonDialog1
    .FileName = ""
   
    .InitDir = App.Path & "\lists"
    .Filter = "Text Files (*.txt)|*.txt"
    .ShowOpen
    If Len(.FileName) Then
        If mnuClearListBeforeAddingNewUsers.Checked Then List1.Clear
        UserIDFilename = .FileName
        Set fs2 = New FileSystemObject
        Set ts2 = fs2.OpenTextFile(.FileName, ForReading, False)

        Do While Not ts2.AtEndOfStream
            List1.AddItem (ts2.ReadLine)
        Loop

        ts2.Close
        Set ts2 = Nothing
    End If
End With
Label8 = List1.ListCount & " IDs Loaded"
End Sub
0
 
LVL 15

Accepted Solution

by:
SnowFlake earned 1000 total points
ID: 19573116
use
CommonDialog1.Flags = cdlOFNAllowMultiselect

you can also look here:
http://vbnet.mvps.org/index.html?code/faq/cdlgmultiselect.htm
to see hot to handle the common dialg control to allow multi select

and have a look here: to see how to use the results.
http://vb-helper.com/howto_select_multiple_files.html


SnowFlake
0
 
LVL 2

Expert Comment

by:tonym001
ID: 19583012
Hi Tak
Before I even start -more info required
How do want to select the files to put in the list box?
Is it wildcard eg *.txt, is it date related, are the files in a text file, do you want to keep a record of files already processed?

You see what I mean - more info

Not that I will get the points another 'expert' will read your response and point you to another link :-(
0
 

Author Comment

by:Takamine334
ID: 19585518
It's just text files listed in a folder.
0
 
LVL 2

Assisted Solution

by:tonym001
tonym001 earned 1000 total points
ID: 19586314
Ok I would do the following

Private Sub FillListBoxFiles()
'add a reference to Microsoft Scripting Runtime - scrrun.dll
Dim mFso As New FileSystemObject
Dim mFolder As Folder
Dim mFiles As Files
Dim mFile As File
Dim strFolders() As String
Dim intCount As Integer


'if you need not wish to add a reference then replace the mFso and all file(s) and folder(s) declarations with object
'for instance
'Dim mFso as Object
'then
'Set mFso = CreateObject("Scripting.FileSystemObject")
'populate the names of the folders you wish to check
ReDim strFolders(1)
'obviously you can make this more sophisticated
strFolders(0) = "C:\Test"
strFolders(1) = "C:\Test1"
For intCount = 0 To UBound(strFolders)
    'Check the folder exists - never trust a user
    If mFso.FolderExists(strFolders(intCount)) Then
        'Set the folder object to the
        Set mFolder = mFso.GetFolder(strFolders(intCount))
        'Set the Files object to files within the folder
        Set mFiles = mFolder.Files
        'Enumerate files
        For Each mFile In mFiles
            'Check the file type - in this case .txt files
            If UCase(Right(mFile.Name, 3)) = "TXT" Then
                'add to list box
                List1.AddItem mFile.Name
                'alternatively add the full path
                'List1.AddItem mFile.Path
            End If
        Next
    End If
   
Next
End Sub
 
Hope this helps
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20238326
Forced accept.

Computer101
EE Admin
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Find out what you should include to make the best professional email signature for your organization.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question