Import a text file into visual basics

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jyoti Khalap
    New Member
    • Oct 2006
    • 2

    Import a text file into visual basics

    HI

    Can Anyone help me out with my problem its very urgent

    I want to import text file to my visual basics application because everytime its a new text file depending on that text file i want to generate my report

    thanx in advance

    jyoti
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Originally posted by Jyoti Khalap
    HI

    Can Anyone help me out with my problem its very urgent

    I want to import text file to my visual basics application because everytime its a new text file depending on that text file i want to generate my report

    thanx in advance

    jyoti
    Hi. You could take a look at the FileSystemObjec t

    Comment

    • djpaul
      New Member
      • Oct 2006
      • 137

      #3
      or use the stream in visual basic.....
      Works fine...
      ---------------------------------------------------------------------------------------------------
      Dim StreamToDisplay As StreamReader
      StreamReaderToD isplay = _
      New Streamreader("c :\textfile.txt" )
      TextBox1.Text = StreamToDispay. ReadToEnd
      StreamToDisplay .Close()
      TextBox1.Select (0, 0)

      Good luck!
      Paul

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by djpaul
        or use the stream in visual basic.....
        You could also go back to basics (no pun intended).
        Code:
        Dim FileNum As Long, Text As String
        FileNum = FreeFile ' Get the next available file number.
        Open "File.txt" For Input Access Read Shared As #FileNum
        Do Until Eof(FileNum)
          Line Input #FileNum,Text
          ' Process your line of text.
        Loop
        Close #FileNum

        Comment

        • willakawill
          Top Contributor
          • Oct 2006
          • 1646

          #5
          Originally posted by djpaul
          or use the stream in visual basic.....
          Works fine...
          ---------------------------------------------------------------------------------------------------
          Dim StreamToDisplay As StreamReader
          StreamReaderToD isplay = _
          New Streamreader("c :\textfile.txt" )
          TextBox1.Text = StreamToDispay. ReadToEnd
          StreamToDisplay .Close()
          TextBox1.Select (0, 0)

          Good luck!
          Paul
          StreamReader is .NET in case you were looking for it in vb and couldn't find it.

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by willakawill
            StreamReader is .NET in case you were looking for it in vb and couldn't find it.
            Oops!

            I'm glad I didn't go looking for it, then. This is why I usually ask what version people are using.

            Comment

            Working...