Solved

FileListBox

Posted on 2000-03-05
3
275 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 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 code to programmatically convert pdf to excel 21 90
Problem to skip loop 6 57
How to measure sizes and angles in scanned images ? 3 63
Passing a Text Box name to a Sub 6 96
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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

773 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