Results 1 to 4 of 4

Thread: reading textfiles into listbox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    102

    reading textfiles into listbox

    Can anybody give me advice or some code here

    What I want to do is load up file names from a particular folder called Orders into a list box. All files will be textfiles and called OrderNumber1.txt, OrderNumber2.txt etc.

    I then want the selected file to load into a richtext box

    For this, would this command rtb.Loadfile( path & list1.text) work?

    Ay ideas welcome.

  2. #2
    Frenzied Member John McKernan's Avatar
    Join Date
    Jan 2002
    Location
    SE PA
    Posts
    1,295
    You could use a FileListBox which is an intrinsic vb control and should be in your toolbox.

    At run-time, you set the .Path property of the filelistbox to the desired path. The file selected byu the user will be returned in the .FileName property.

    Then to load your rtb:
    VB Code:
    1. rtb.Loadfile( File1.Path & "\" & File1.FileName)

  3. #3
    New Member
    Join Date
    Sep 2002
    Location
    IRAN
    Posts
    6

    Wink

    Hi , I think this source may be interesting for you .

    ' Rem cmbFile is a combo box
    Dim FName as string
    Dim Title as string
    FName = App.Path + "\Text1.txt"
    If Dir(FName) <> "" Then
    Open FName For Input As #1
    Do While Not EOF(1)
    Line Input #1, Title
    cmbFile.AddItem Title
    Loop
    Close #1
    End If
    If cmFile.ListCount < 1 Then
    cmbFile.AddItem ("Empty text file")
    End If
    cmbFile.ListIndex = 0

  4. #4
    Fanatic Member scr0p's Avatar
    Join Date
    Oct 2002
    Location
    VA
    Posts
    720
    ' Rem cmbFile is a combo box

    you can use ' for a comment, you dont need the rem keyword.
    asdf

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