Solved

FileListBox

Posted on 2000-03-05
3
280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 50 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

738 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