B bishmedia Member Licensed User Longtime User Apr 6, 2013 #1 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 Code: 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 Attachments listview.jpg 61.7 KB · Views: 609
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 Code: 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
NJDude Expert Licensed User Longtime User Apr 6, 2013 #2 Something like this: Code: Dim Test As String Dim Items() As String Test = File.ReadString(File.DirAssets, "test.txt") Items = Regex.Split(",", Test) Msgbox(Items(0).Replace(QUOTE, ""), "") The contents of "test.txt" is something like Code: "AB15", "something", "more", "even more" Upvote 0
Something like this: Code: Dim Test As String Dim Items() As String Test = File.ReadString(File.DirAssets, "test.txt") Items = Regex.Split(",", Test) Msgbox(Items(0).Replace(QUOTE, ""), "") The contents of "test.txt" is something like Code: "AB15", "something", "more", "even more"
B bishmedia Member Licensed User Longtime User Apr 6, 2013 #3 i keep getting an error on yours and my try.... Parsing code. Error Error parsing program. Error description: Syntax error. Occurred on line: 35 35 ListView1.AddSingleLine(Items(0).Replace(QUOTE,*""),*"") Click to expand... Code: Do While line <> Null Dim Items() As String line = Reader.ReadLine Items = Regex.Split(",", line) ListView1.AddSingleLine(Items(0).Replace(QUOTE,*""),*"") Loop Upvote 0
i keep getting an error on yours and my try.... Parsing code. Error Error parsing program. Error description: Syntax error. Occurred on line: 35 35 ListView1.AddSingleLine(Items(0).Replace(QUOTE,*""),*"") Click to expand... Code: Do While line <> Null Dim Items() As String line = Reader.ReadLine Items = Regex.Split(",", line) ListView1.AddSingleLine(Items(0).Replace(QUOTE,*""),*"") Loop
NJDude Expert Licensed User Longtime User Apr 6, 2013 #4 It should be: Code: ... Items(0) = Items(0).Replace(QUOTE, "") ListView1.AddSingleLine(Items(0)) ... Last edited: Apr 6, 2013 Upvote 0
B bishmedia Member Licensed User Longtime User Apr 7, 2013 #5 Many thanks, the listview populates great but then comes up with an error as follows... java.lang.NullPointerException Click to expand... If i press yes to continue it runs fine, how can i stop this error, my code now is... Code: 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 Upvote 0
Many thanks, the listview populates great but then comes up with an error as follows... java.lang.NullPointerException Click to expand... If i press yes to continue it runs fine, how can i stop this error, my code now is... Code: 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
agraham Expert Licensed User Longtime User Apr 7, 2013 #6 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. Code: 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 Upvote 0
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. Code: 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
B bishmedia Member Licensed User Longtime User Apr 7, 2013 #7 oh yes i can see it now, many thanks Upvote 0