vb.net - VB Loading a list of variables from a text document -


i'm trying load list of variables formatted this:

5, 6, 3, 3, 

etc, , i'm trying output them variables this:

strength = variableslist(1) agility = variableslist(2) 

but far, i've not been able find solution seems work i'm trying do.

i'm working with:

dim destination string = environment.getfolderpath("c:\roll20output\class" + outputclass + "2.txt")         dim filereader1 new streamreader(destination)         dim contents1 string         dim index integer = 0         while filereader1.peek <> -1             contents1 = filereader1.readline             dim array new arraylist             array.addrange(contents1.split(","))             variableslist.add(array)         end while          strength = variableslist(1)         agility = variableslist(2) 

but far can't seem output.

would able help?

thanks

you using lot of outdated stuff in code (reading file streamreader, arraylist instead of list<t>, etc.). suggest following (untested):

' returns array 1 string per line dim lines = file.readalllines("c:\...\somefile.txt")  ' remove trailing `,` - linq magic lines = (from s in lines select s.trimend(","c)).toarray()  dim strength = cint(lines(0)) dim agility = cint(lines(1)) ... 

if rid of useless trailing commas, can skip second step. if use only commas instead of new lines, first step becomes:

dim lines = file.readalltext("c:\...\somefile.txt").split(","c) 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -