I am a newbie programmer. I am trying to write an array to a text file. The array gets its data from a linq query using .ToArray. Everytime the array goes to file I get this in the file: VB$AnonymousType_5`4[system.String,System.String,System.String,System.String][]
My code snippet is this:
Dim search As String
search = InputBox("Enter search string")
If File.Exists("MyData.txt") Then
Dim myfile() As String = File.ReadAllLines("MyData.txt")
Dim query1 = From line In myfile
Let Data = line.Split(":"c)
Let iname = Data(0)
Let idescrip = Data(1)
Let ilocation = Data(2)
Let ivalue = FormatCurrency(Data(3))
Where (search <> iname)
Select iname, idescrip, ilocation, ivalue
Dim newFile() = query1.ToArray
lstDisplay.Items.Add(newFile)
Dim myfile2 = File.CreateText("MyData.txt")
Dim outputLine = newFile
myfile2.WriteLine(outputLine)
myfile2.Close()
Any help would be greatly appreciated! Thanks! :blink:
Question
jdwbasic
HI,
I am a newbie programmer. I am trying to write an array to a text file. The array gets its data from a linq query using .ToArray. Everytime the array goes to file I get this in the file: VB$AnonymousType_5`4[system.String,System.String,System.String,System.String][]
My code snippet is this:
Dim search As String
search = InputBox("Enter search string")
If File.Exists("MyData.txt") Then
Dim myfile() As String = File.ReadAllLines("MyData.txt")
Dim query1 = From line In myfile
Let Data = line.Split(":"c)
Let iname = Data(0)
Let idescrip = Data(1)
Let ilocation = Data(2)
Let ivalue = FormatCurrency(Data(3))
Where (search <> iname)
Select iname, idescrip, ilocation, ivalue
Dim newFile() = query1.ToArray
lstDisplay.Items.Add(newFile)
Dim myfile2 = File.CreateText("MyData.txt")
Dim outputLine = newFile
myfile2.WriteLine(outputLine)
myfile2.Close()
Any help would be greatly appreciated! Thanks! :blink:
Link to comment
Share on other sites
12 answers to this question
Recommended Posts