VB.NET string parsing in text file..

jason33

New member
Joined
Apr 26, 2007
Messages
2
Programming Experience
1-3
I am unsure how to do this efficiently... I have an external text file that I want to be able to change values depending on the value in the text box in my form .

for example...mytext.txt looks like this

state1 minnesota
state2 "florida"
newstate3 #arizona
state4 Hawaii
...
...

I know that depending on the text box which field would need to be changed i.e. textbox1 = state 1. and textbox4 = state4 but am not sure how to get to the starting value and replace the value with what was in my text box. Do I use a streamReader to get me to the right line. but then how to I get to the value and replace content...It is not the same amount of spaces in between the keyword and value....

I am new to this use of vb but can see how it would be awesome for config values. just trying to figure out how to do this.

Thanks for your help in advance.
 
Are you creating the text file specifically to store configuration data or is this an existing text file you are trying to modify? If you are creating the file for configuration data, it is more appropriate to use XML as a storage medium.

It's been quite some time since I have used .NET 1.1 (they're up to V3 now) and I don't believe it includes the setting classes, but if you are willing to upgrade to V2 as least, you will find storing configuration data has been greatly simplified.
 
Yes, this is an existing file that I am already writing to so i can't change it to xml. It is just a plain .txt file that is used by another application. I also think I am stuck with the version that I am running with. :(
 
in situations like this I normally jsut read/write the entire file. You will have to implement some parsing of the file yourself, i'm afraid..
 
Back
Top