J
Jurgen Oerlemans
Hello, probably a simple one:
I want to store some settings to a textfile so they are default when the
user re-opens the program.
For this I need to read the text file.
I tried to use the example-code from msdn which I pasted under a
commandbutton :
Imports System ----> Syntax error <-----
Imports System.IO -----> Syntax error <-----
Class Test ----> statement cannot appear within a
method body. End of method assumed
Public Shared Sub Main()
Try
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New
er("TestFile.txt") ---> type Streamreader is not defined <------
Dim line As String
' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()
Console.WriteLine(Line)
Loop Until line Is Nothing
sr.Close()
Catch E As Exception
' Let the user know what went wrong.
Console.WriteLine("The file could not be read:")
Console.WriteLine(E.Message)
End Try
End Sub
End Class
I am sure I am doing some basic things very wrong; Can someone help me
reading the textfile?
Any help appreciated.
Jurgen Oerlemans
I want to store some settings to a textfile so they are default when the
user re-opens the program.
For this I need to read the text file.
I tried to use the example-code from msdn which I pasted under a
commandbutton :
Imports System ----> Syntax error <-----
Imports System.IO -----> Syntax error <-----
Class Test ----> statement cannot appear within a
method body. End of method assumed
Public Shared Sub Main()
Try
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New
er("TestFile.txt") ---> type Streamreader is not defined <------
Dim line As String
' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()
Console.WriteLine(Line)
Loop Until line Is Nothing
sr.Close()
Catch E As Exception
' Let the user know what went wrong.
Console.WriteLine("The file could not be read:")
Console.WriteLine(E.Message)
End Try
End Sub
End Class
I am sure I am doing some basic things very wrong; Can someone help me
reading the textfile?
Any help appreciated.
Jurgen Oerlemans