vb.net - read specific values from text file -


i have following visual basic code, part of custom class. want simple , effective way(use little computer resources) assign "value1" value(100) "_field1","value2" value(8) "_field2" etc. nice ideas? thanks

private sub readcrnfile()     'read files , assing values properties     dim sr new io.streamreader(_filename)      _field1 = sr.readtoend()     _field2 = sr.readtoend()     _field3 = sr.readtoend()      sr.close()  end sub 

where _filename full path text file looks this:

value1: 100

value2: 8

value3: 80

change _field1, _field2 , _field3 variables list(of string) (i.e. named field) , access each field using index (field(0), field(1), field(2)).

dim field new list(of string)  private sub readcrnfile()     each line in file.readalllines(_filename)         = 1 3             if line.contains("value" & i)                 field.add(line.substring(line.indexof(":") + 2))             end if         next     next end sub 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -