Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

FileListBox

Posted on 2000-03-05
3
Medium Priority
?
287 Views
Last Modified: 2010-05-02
Can someone tell me how can I make a command button that when you click it a text box or a label will show the current files of a FileListBox... I know why don't I just place a FileListBox...because I don't want to...
Please tell me how to do this.
0
Comment
Question by:aBsOlUt
3 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2584763
You can use this code (you need a reference to the Microsoft Scripting runtime):

Private Sub Command1_Click()
Dim objFile As File
Dim objFiles As Files
Dim objFolder As Folder
Dim objFSO As FileSystemObject

    Set objFSO = New FileSystemObject
    Set objFolder = objFSO.GetFolder(App.Path)
    Set objFiles = objFolder.Files
    For Each objFile In objFiles
        Text1.Text = Text1.Text + objFile.Name & vbCrLf
    Next
End Sub
0
 
LVL 1

Expert Comment

by:vbyuval
ID: 2584952
?
0
 

Accepted Solution

by:
sartoris earned 200 total points
ID: 2584992
Private Sub Command1_Click()
    Dim intFileCount As Integer
    For intFileCount = 0 To File1.ListCount - 1
        File1.ListIndex = intFileCount
        Label1.Caption = Label1.Caption & File1.FileName & vbCrLf
    Next
End Sub
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

885 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