Results 1 to 7 of 7

Thread: [RESOLVED] endofstream

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2013
    Posts
    485

    Resolved [RESOLVED] endofstream

    Hello
    I am working through a tutorial written in vb.net 2010 . I am using 2010 professional. The tutorial calls for the use of .endofstream , I get an error message (Error 1 'endofstream' is not a member of 'System.IO.StringReader'.

    Code:
      Private Sub loadmap(ByVal mapfile As String)
    
            Try
                Dim sr As New IO.StringReader(mapfile & ".map")
                Dim strline As String = ""
                Dim x As Integer = 0
                Dim y As Integer = 0
    
                Do Until sr.endofstream
    
    
    
                    strline = sr.ReadLine
                    strline = strline.Replace(strline.LastIndexOf(","), "")
                    For Each item As String In Split(strline, ",", -1)
                        If item = "" Then
                            item = 0
                        End If
                        If x <= mapwidth Then
                            map(x, y, 0) = Int(item)
                        End If
                        x += 1
    
                    Next
                    x = 0
                    y += 1
                Loop
                sr.Close()
                sr.Dispose()
            Catch ex As Exception
                MsgBox("map '" & mapfile & "' could not be loaded." & vbCrLf & ex.Message, MsgBoxStyle.Critical, "error")
            End Try
        End Sub
    The best I can do is readtoend which generates a run time error conversion from string "map1.map" to type boolean is not valid

    I have two questions 1)why don't I have endofstream? 2) how do I make the do until loop work correctly?
    Thanks
    George

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    Re: endofstream

    You don't have endofstream because System.IO.StringReader doesn't have endoftstream.

    Presumably the tutorial is expecting you to use a System.IO.StreamReader. The answer to most subsequent questions should be addressed in the link below.

    https://docs.microsoft.com/en-us/dot...r?view=net-5.0

    Good luck.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2013
    Posts
    485

    Re: endofstream

    I am sorry I did not find the link useful (it is in c# but I ran it through a converter) the tutorial was written in vb.net 2010. I've imported system and system.io (did not help) Consider me to be dense and requiring more explanation and examples.

  4. #4
    Frenzied Member
    Join Date
    May 2014
    Location
    Central Europe
    Posts
    1,372

    Re: endofstream

    streamreader <> stringreader. got it? you are using the wrong object.

  5. #5
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    845

    Re: endofstream

    Quote Originally Posted by georgesutfin View Post
    I am sorry I did not find the link useful (it is in c# but I ran it through a converter) the tutorial was written in vb.net 2010. I've imported system and system.io (did not help) Consider me to be dense and requiring more explanation and examples.
    at the top right of the page you have to possibility to change the language to VB...
    Name:  there.jpg
Views: 143
Size:  8.1 KB
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2013
    Posts
    485

    Re: [RESOLVED] endofstream

    Thank you! It makes sense now.
    optionbase1 your post WAS helpful.
    I was reading streamreader incorrectly

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2013
    Posts
    485

    Re: [RESOLVED] endofstream

    delaney thank you I didn't know that

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