?
Solved

Visual Basic Folders

Posted on 2007-03-23
7
Medium Priority
?
168 Views
Last Modified: 2010-08-05
How can i get my application to populate a list box with a list of all the folders that exist in the application path. so say ive got folder1, folder2, and folder3.

i want the list box to have:
folder1
folder2
folder3

i want then to have it so that when i click on folder1 in the list box, that a picture appears in the picture box on the right that is called folder1.jpg and a text box to populate with a file called text.txt thanks. if i can get this solved within the next 12 hours ill try offer more points if possible
0
Comment
Question by:aidanmcg33
[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
7 Comments
 

Author Comment

by:aidanmcg33
ID: 18784225
i forgot to add that im using visual basic 6, and that if this isnt possible, then id be willing to use a text file in the app path with a list of the folder names inside it
0
 

Author Comment

by:aidanmcg33
ID: 18784241
got this code:


Path = "J:\DVD\"
    Subdir = Dir(Path, vbDirectory)
    Do While Len(Subdir)
        If (GetAttr(Path & Subdir) And vbDirectory) Then
            lstFilms.AddItem Subdir
        End If
        Subdir = Dir
    Loop


how do i get it to change the picture in the  picture box by whats in the folder?
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 18784243
"when i click on folder1 in the list box, that a picture appears in the picture box on the right that is called folder1.jpg and a text box to populate with a file called text.txt"

Did you by chance mean text1.txt instead of text.txt?  So if you clicked on Folder2 then you would want folder2.jpg and text2.txt?

Where are these files located?  Are they also in the app path? ...or are they located within each respective subfolder?
0
 

Author Comment

by:aidanmcg33
ID: 18784279
Dim Path As String
Dim Subdir As String

Private Sub Form_Load()

    Path = "J:\DVD\"
    Subdir = Dir(Path, vbDirectory)
    Do While Len(Subdir)
        If (GetAttr(Path & Subdir) And vbDirectory) Then
            lstFilms.AddItem Subdir
        End If
        Subdir = Dir
    Loop

End Sub

Private Sub lstFilms_Click()
Dim temp As String
Dim handle As Integer

On Error GoTo error:

    temp = lstFilms.Text
    picpath = Path & Subdir & temp & "\" & temp & ".jpg"
    imgPicture.Picture = LoadPicture(picpath)
    lblDescription.Caption = "Descrition: " & temp
    despath = Path & Subdir & temp & "\Description.txt"
    txtDescription.Text = FileText(despath)
error:
End Sub


Function FileText(ByVal filename As String) As String
    Dim handle As Integer
   
    If Len(Dir$(filename)) = 0 Then
        Err.Raise 53
    End If
   
    handle = FreeFile
    Open filename$ For Binary As #handle
    FileText = Space$(LOF(handle))
    Get #handle, , FileText
    Close #handle
End Function
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 19184841
PAQed with points refunded (125)

Computer101
EE Admin
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Suggested Courses
Course of the Month14 days, 21 hours left to enroll

771 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