Results 1 to 4 of 4

Thread: Load a Text file

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2010
    Posts
    11

    Load a Text file

    how do i load a textfile into a listbox in a form?

  2. #2
    Junior Member
    Join Date
    Nov 2010
    Posts
    25

    Re: Load a Text file

    what you mean text file. like the whole thing or just the name of the text file? the whole text file would be better off in a text box unless you want to list each like as an item in the list box.

    i would have to research as i am new but i would google file system movement and opening and closing files. i am sure vb has something similiar to filereader and filewriter in java or fopen and such. once yu open it the text file can be manipulated my reading it and doing what you want with it until EOF.

    look for chr(13) and chr(10) to denote end line and such. i would look this up becausE IT IS USEFUL AND TELL YOU THE CODE BUT I AM NEEDING A SMOKE RIGHT NOW. IF I GET NBACK AND YOU WANT SOME MORE LET ME KNOW WHAT WITH THE TEXT FILE YOU WANT TO DO WITH A LISTBOX EXACTLY.

    sorry if this doesn;t directly answer your question.

  3. #3
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Load a Text file

    Try
    vb Code:
    1. Private Sub Command1_Click()
    2. Dim arrLines() As String
    3. Dim lngCount As Long
    4. Dim i As Long
    5. Open "c:\textfile.txt" For Input As #1
    6.    arrLines = Split(Input(LOF(1), #1), vbCrLf)
    7. Close #1
    8. lngCount = UBound(arrLines)
    9. For i = 0 To lngCount
    10.     List1.AddItem arrLines(i)
    11. Next
    12. End Sub

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