How can i get say the first bit of the text file into the listview eg AB15 without the quotes.???
I believe i use something called Regex.Split
B4X:
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("csv_listview")
Dim Reader As TextReader
Reader.Initialize(File.OpenInput(File.DirAssets, "pc.csv"))
Dim line As String
line = Reader.ReadLine
Do While line <> Null
line = Reader.ReadLine
ListView1.AddSingleLine(line)
Loop
End Sub
Dim Test As String
Dim Items() As String
Test = File.ReadString(File.DirAssets, "test.txt")
Items = Regex.Split(",", Test)
Msgbox(Items(0).Replace(QUOTE, ""), "")
Do While line <> Null
Dim Items() As String
line = Reader.ReadLine
Items = Regex.Split(",", line)
ListView1.AddSingleLine(Items(0).Replace(QUOTE,*""),*"")
Loop
If i press yes to continue it runs fine, how can i stop this error, my code now is...
B4X:
Do While line <> Null
Dim Items() As String
line = Reader.ReadLine
Items = Regex.Split(",", line)
Items(0) = Items(0).Replace(QUOTE, "")
ListView1.AddSingleLine(Items(0))
Loop
I assume you must have set line before entering the loop in which case ReadLine is in the wrong place and you are ignoring the first line and processing the null at the end which is giving the exception.
B4X:
line = Reader.ReadLine
Do While line <> Null
Dim Items() As String
Items = Regex.Split(",", line)
Items(0) = Items(0).Replace(QUOTE, "")
ListView1.AddSingleLine(Items(0))
line = Reader.ReadLine
Loop