-
Jul 23rd, 2021, 10:12 PM
#1
Thread Starter
Hyperactive Member
[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
-
Jul 23rd, 2021, 10:26 PM
#2
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.
-
Jul 24th, 2021, 07:06 AM
#3
Thread Starter
Hyperactive Member
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.
-
Jul 24th, 2021, 07:55 AM
#4
Re: endofstream
streamreader <> stringreader. got it? you are using the wrong object.
-
Jul 24th, 2021, 08:45 AM
#5
Re: endofstream
Originally Posted by georgesutfin
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...
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)
-
Jul 24th, 2021, 08:49 AM
#6
Thread Starter
Hyperactive Member
Re: [RESOLVED] endofstream
Thank you! It makes sense now.
optionbase1 your post WAS helpful.
I was reading streamreader incorrectly
-
Jul 24th, 2021, 08:52 AM
#7
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|