Results 1 to 4 of 4

Thread: reading text file?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Posts
    91

    reading text file?

    if i have a text file how do i put the lines into an array?

    edit: i wanna chek if its there, if not i wanna make it, if so i wanna load it.
    Last edited by Synth3t1c; Jun 13th, 2004 at 04:06 PM.

  2. #2
    Addicted Member
    Join Date
    Nov 2002
    Posts
    216
    Go here and download this code : http://www.planet-source-code.com/vb...=121&lngWId=10


    I had the same problem then i got the project that that link will give you.


    Edit- it is in vb.net '02 version
    Quote Originally Posted by randem
    You think you are confused? Try reading what you wrote...

  3. #3
    Lively Member ayan's Avatar
    Join Date
    Jan 2004
    Posts
    112
    getting every line of the text file
    VB Code:
    1. Imports System.IO
    2. Module Module1
    3.  
    4.    Sub Main()
    5.       Dim s As New StreamReader("..\module1.vb")
    6.       Dim ss(0) As String
    7.       Dim i As Integer = 0
    8.       While Not s.Peek = -1
    9.          ReDim Preserve ss(i)
    10.          ss(i) = s.ReadLine
    11.          i += 1
    12.       End While
    13.       Dim sss As String
    14.       For Each sss In ss
    15.          Console.WriteLine(sss)
    16.       Next
    17.    End Sub
    18.  
    19. End Module

  4. #4
    Member
    Join Date
    May 2001
    Location
    North East Germany
    Posts
    46
    Hi,

    you must open the textfile with "Open" mode only. But don't forget to put the open statement in "try ... catch.... end try",

    because if the file dosn't exist you will be kicked out of your programm

    bye
    http://www.fin-sn.de

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