Results 1 to 5 of 5

Thread: Easiest Way to remove the File Extension From The FileList Box?

  1. #1

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    Easiest Way to remove the File Extension From The FileList Box?

    Hey ya,

    Currently:

    FileList.FileName is showing as:

    MyFile.sve

    How can i make it show as:

    MyFile

    But, the FileName Value remain as:

    MyFile.sve?

    Tnx
    Wayne

  2. #2
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    check the object browser and see if there's a property that lets you configure the file name display to show up without extent.

    You could always hide the file box and transfer all the names over to a regular list box minus the extent --- that's a little baggy, but it will get the job done.

  3. #3
    Addicted Member PhilRob56's Avatar
    Join Date
    Oct 2002
    Location
    New York
    Posts
    249
    Perhaps...just a thought....

    Why not synchronize a List Box with the File List box. Make the File List Box hidden.

    VB Code:
    1. Dim sFName as string
    2. Dim lPos as long
    3. Dim i      as long
    4.  
    5. FileList1.path = "C:\My Documents"
    6. List1.Clear
    7.  
    8. For i = 0 To FileList1.Listcount - 1
    9.     lPos = InstrRev(FileList1.List(i),".")
    10.     If lPos <> 0 then
    11.         sFName = Left(FileList1.List(i), LPos-1)
    12.     Else
    13.         sFName = FileList1.List(i)
    14.     End If
    15.     List1.Additem sFName
    16. Next i


    ....just a suggestion....
    Some days you're the dog,
    and some days you're the hydrant.


    VB6 Enterprise

  4. #4
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    Here is another approach: similar but no FileListbox at all:
    VB Code:
    1. Option Explicit
    2. Dim FileList() As String
    3.  
    4. Private Sub Dir1_Change()
    5. '=========================
    6. Dim i%, pos%, MyPath$, FileName$
    7.  
    8.     MyPath = Dir1.Path
    9.     FileName = Dir(MyPath, vbNormal)
    10.     Do While FileName <> ""
    11.         If FileName <> "." And FileName <> ".." Then
    12.             If (GetAttr(MyPath & FileName) And vbNormal) = vbNormal Then
    13.                 ReDim FileList(i)
    14.                 FileList(i) = FileName
    15.                 pos = InStrRev(FileName, ".")
    16.                 List1.AddItem Left(FileName, pos - 1)
    17.                 i = i + 1
    18.             End If
    19.         End If
    20.         FileName = Dir
    21.     Loop
    22.  
    23. End Sub
    24.  
    25. Private Sub Drive1_Change()
    26.     Dir1.Path = Drive1.Drive
    27. End Sub
    Roy

  5. #5
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    Oops, correction:
    VB Code:
    1. '.......
    2. ReDim Preserve FileList(i) 'preserve all data in array
    3. '........
    4.  
    5. Private Sub List1_Click()
    6.     Debug.Print FileList(List1.ListIndex)
    7. End Sub
    Roy

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