vb.net - using the split function to parse through a comma separated line -


solved on own ...

  int1 = cint(line.split(cchar(","))(1)) 

to read contents of text file, line line, using code

    using r streamreader = new streamreader("0trace2.txt")         dim line string         line = r.readline         while (not line nothing)             list.add(line)             line = r.readline             msgbox(line)          loop     end using 

however, file has 4 comma separated values, numbers. need extract each number integer. tried split method ran error

dim int1 integer dim int2 integer dim int3 integer dim int4 integer      using r streamreader = new streamreader("0trace2.txt")         dim line string         line = r.readline         while (not line nothing)             list.add(line)             line = r.readline            'msgbox(line)            int1 = cint(line.split(cchar(","))(1))          loop     end using 

thanks

assuming simple need collect integers file structure like

1,2,3,4 5,6,7,8 9,10,11,12 

you can use list(of integer) collect them all, e.g.:

dim arr new list(of integer)  while (not line nothing)     each s in line.split(",")         arr.add(s)    next      line = r.readline loop 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -