Hi, I'm trying to go back to learn the basics of VB.NET as opposed to muddling on with my own, ancient, subset of VB code.
I have reached the section concerned with 'Text Files' and following this chapter have the following snippet of code:
This works to a certain extent, but when I read the text in ListBox1, I find some characters have not been read-in correctly, it's true that some of them are accented characters but most frequently they are just a space (Chr 32) and all are usually replaced by ? (Chr 63).
Going back to my ancient subset, I re-wrote the code thus:
Running this code produces no errors at all...
I think I've copied anything as instructed so I'm wondering why there are errors in the first results.
Poppa.
I have reached the section concerned with 'Text Files' and following this chapter have the following snippet of code:
vb.net Code:
Dim FilePath As String = "C:\TmpTest\Place_Names.txt" Dim Strg As String Dim oRead As New System.IO.StreamReader(FilePath) Do While objRead.Peek <> -1 Strg = objRead.ReadLine ListBox1.Items.Add(Strg) Loop objRead.Close() Else MsgBox("Can't find file " & FilePath) End If
This works to a certain extent, but when I read the text in ListBox1, I find some characters have not been read-in correctly, it's true that some of them are accented characters but most frequently they are just a space (Chr 32) and all are usually replaced by ? (Chr 63).
Going back to my ancient subset, I re-wrote the code thus:
vb.net Code:
Dim FilePath As String = "C:\TmpTest\Place_Names.txt" Dim Strg As String FileOpen(1, FilePath, OpenMode.Input) While Not EOF(1) Strg = LineInput(1) ListBox1.Items.Add(Strg) End While FileClose(1) Else MsgBox("Can't find file " & FilePath) End If
Running this code produces no errors at all...
I think I've copied anything as instructed so I'm wondering why there are errors in the first results.
Poppa.