Results 1 to 8 of 8

Thread: DirListBox

  1. #1

    Thread Starter
    Member Visual Programmer's Avatar
    Join Date
    Dec 2000
    Posts
    59
    Hi, I have a DirListBox (the yellow folder thing on your tool box) and a textbox
    so how do I copy line for line from the dirlistbox to the text box?

    hope that was clear



    Visual Programmer
    VP/Sonic taking on the (vb) world, one post at a time.

  2. #2
    Guest
    Code:
    Private Sub Command1_Click()
    
        Dim iDir As Integer
        For iDir = 0 To Dir1.ListCount - 1
            Text1.Text = Text1.Text & Dir1.List(iDir) & vbCrLf
        Next iDir
    
    End Sub

  3. #3

    Thread Starter
    Member Visual Programmer's Avatar
    Join Date
    Dec 2000
    Posts
    59
    thanks matthew, now how would I go about doing the same thing but for a file list, instead of the dir list



    Visual Programmer
    VP/Sonic taking on the (vb) world, one post at a time.

  4. #4
    Guest
    Same exact thing, just change Dir1 to File1 and iDir to iFile if you want.

    Code:
    Private Sub Command1_Click()
    
        Dim iFile As Integer
        For iFile = 0 To File1.ListCount - 1
            Text1.Text = Text1.Text & File1.List(iFile) & vbCrLf
        Next iFile
    
    End Sub

  5. #5

    Thread Starter
    Member Visual Programmer's Avatar
    Join Date
    Dec 2000
    Posts
    59
    Thanks once again.....
    and 1 final question.....
    is it possible to get rid of the extension?
    VP/Sonic taking on the (vb) world, one post at a time.

  6. #6
    Guest
    To remove the file extension:

    Code:
    Private Sub Command1_Click()
    
        Dim iFile As Integer
        For iFile = 0 To File1.ListCount - 1
            Text1.Text = Text1.Text & Left(File1.List(iFile), Len(File1.List(iFile)) - 4) & vbCrLf
        Next iFile
    
    End Sub

  7. #7
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Matthew, not all extensions are 4 characters long (3 + . = 4 )

    So use this API function to get rid of the extension:

    Code:
    Declare Sub PathRemoveExtension Lib "shlwapi.dll" Alias "PathRemoveExtensionA" (ByVal pszPath As String)
    
    Private Sub GetRidOfExt_Click()
    Dim Path$
    Path = "c:\file.ext" 'fill the path into a string
    PathRemoveExtension Path 'get the path without the ext.
    MsgBox Path 'show the new path without ext.
    End Sub
    cool huh? : )

    wheter your extension is .mp3 or .pl, it removes it
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  8. #8

    Thread Starter
    Member Visual Programmer's Avatar
    Join Date
    Dec 2000
    Posts
    59
    Thanks 2 both



    Visual Programmer
    VP/Sonic taking on the (vb) world, one post at a time.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width