Results 1 to 9 of 9

Thread: RAW ASCII file reader

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    4

    RAW ASCII file reader

    HI! looking for a simple example of opening and reading in a loop a raw ascii file 1 character at a time in vb.net

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: RAW ASCII file reader

    Use system.IO.streamreader class and call its Read method then convert the returned value to a char. Something like this:
    Code:
    Using reader As New IO.StreamReader("file path here")
                Dim ch As Char
                While reader.Peek >= 0
                    ch = Chr(reader.Read())
                    'Do whatever you like with this char here
                End While
            End Using
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: RAW ASCII file reader

    Removed, stanav's example is more complete.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    4

    Re: RAW ASCII file reader

    i was seeing suggestions that included:

    fileope() and Lineinput()

    are these suggestions wrong or are they a different way of doing the same thing?

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    4

    Re: RAW ASCII file reader

    Quote Originally Posted by Jenner View Post
    Removed, stanav's example is more complete.
    would you mind posting it

  6. #6
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: RAW ASCII file reader

    I just did the two most essential lines from his example. He's actually looping through the output. I just did:

    Code:
    Dim st As New IO.StreamReader("C:\MyASCIIFile.txt")
    Convert.ToChar(st.Read())
    As I said, his example is much more complete.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  7. #7

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    4

    Re: RAW ASCII file reader

    Quote Originally Posted by bponce23 View Post
    i was seeing suggestions that included:

    fileope() and Lineinput()

    are these suggestions wrong or are they a different way of doing the same thing?
    anyone care to comment on these two functions with regards on how to use them for reading an raw ascii file?

  8. #8
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: RAW ASCII file reader

    They are VB6 legacy functions and since you're writing in .net language now, you should use .net classes/methods. On the other hand, if you just want to know what those methods do, Google it and you'll be flooded with results.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  9. #9
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: RAW ASCII file reader

    Yea, those aren't used anymore. There are far better ways to read text files.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

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