Results 1 to 3 of 3

Thread: Erhm, help..

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    5
    Okay, this has to do with listboxes. I am trying to get it in the Form_Load part, I want the list box to look for all the .rpr files in the folder, and make them list items (minus the .rpr). Also, I need it to refresh at will. Can someone help me with this?

    --
    Visual Basic 6

  2. #2
    Guest
    Why don't you just use a FileListBox?

    To refresh the listbox, just use file1.Refresh

    Or for a listbox, as you want:

    Code:
    Dim FileFinder
    FileFinder = Dir("C:\*.rpr")
    Do Until FileFinder = ""
    List1.AddItem LCase(FileFinder)
    FileFinder = Dir
    Loop
    [Edited by Matthew Gates on 06-29-2000 at 02:44 AM]

  3. #3
    Lively Member
    Join Date
    Jun 2000
    Location
    Belgium
    Posts
    77

    Smile

    For make this, you must have a listbox (list1) and a command button to refersh the list (CmdRefresh)
    In his case, your code would something like this

    Code:
    Private Sub CmdRefresh_Click()
     Dim File As String
     ' replace c:\ by your directory
     File = Dir("C:\" & "*.rpr")
     List1.Clear
     While File <> ""
      List1.AddItem GetFileNameWithoutExtension(File)
      File = Dir
     Wend
    End Sub
    
    Function GetFileNameWithoutExtension(ByVal FileName As String) As String
     ' This function suppress the extension
     Dim FileN As String
     Dim TabFile() As String
     Dim i As Integer
     FileName = GetFileName(FileName)
     ' we split the string with the separator "." and send this in a array (SPLIT is a VB function)
     TabFile = Split(FileName, ".")
     FileN = ""
     ' we re-built the string without the last element of the array
     ' Uboud give then last index use in the array
     For i = 0 To UBound(TabFile) - 1
      If FileN <> "" Then FileN = FileN & "."
      FileN = FileN & TabFile(i)
     Next i
     GetFileNameWithoutExtension = FileN
    End Function
    KWell

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