|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
[VB2008] How to replace lines in a textfile?I'm pretty new with VB, especialy with 2008 Express :-p So i need your help... I have a text file containing: VERSION 3 ADDEDVERSION 5 OPTION_GUILD_RECRUITMENT_CHANNEL AUTO CHANNELS guild 1 3 dutchworld 1 4 WorldTrade 1 5 GMhelp 1 6 END ZONECHANNELS 16777216 COLORS SAY 255 255 255 .... .... And i want to replace the part between CHANNELS and END I allready found a way to read those lines and change it in the way i want and put it in an array ( Dim channel_names(0 To 10) As String ) Now i want to replace those 4 lines with my array. Does anyone has an idea to do this? Or can anyone give me some hints or examples? Thanks, Maurice
Show quote
Hide quote
"Maurice van 't Loo" <nospam@nospam.nl> schrieb Put 'em in a List(Of String) and you can remove and add items using the Add, > Hi, > > I'm pretty new with VB, especialy with 2008 Express :-p So i need > your help... > > I have a text file containing: > > VERSION 3 > ADDEDVERSION 5 > OPTION_GUILD_RECRUITMENT_CHANNEL AUTO > CHANNELS > guild 1 3 > dutchworld 1 4 > WorldTrade 1 5 > GMhelp 1 6 > END > ZONECHANNELS 16777216 > COLORS > SAY 255 255 255 > .... > .... > > And i want to replace the part between CHANNELS and END > I allready found a way to read those lines and change it in the way > i want and put it in an array ( Dim channel_names(0 To 10) As String > ) > > Now i want to replace those 4 lines with my array. > > Does anyone has an idea to do this? > Or can anyone give me some hints or examples? AddRange and RemoveAt methods. Armin
Show quote
Hide quote
On 27 Nov., 10:33, "Armin Zingler" <az.nos***@freenet.de> wrote: Hi Armin,> "Maurice van 't Loo" <nos...@nospam.nl> schrieb > > > > > > > Hi, > > > I'm pretty new with VB, especialy with 2008 Express :-p So i need > > your help... > > > I have a text file containing: > > > VERSION 3 > > ADDEDVERSION 5 > > OPTION_GUILD_RECRUITMENT_CHANNEL AUTO > > CHANNELS > > guild 1 3 > > dutchworld 1 4 > > WorldTrade 1 5 > > GMhelp 1 6 > > END > > ZONECHANNELS 16777216 > > COLORS > > SAY 255 255 255 > > .... > > .... > > > And i want to replace the part between CHANNELS and END > > I allready found a way to read those lines and change it in the way > > i want and put it in an array ( Dim channel_names(0 To 10) As String > > ) > > > Now i want to replace those 4 lines with my array. > > > Does anyone has an idea to do this? > > Or can anyone give me some hints or examples? > > Put 'em in a List(Of String) and you can remove and add items using the Add, > AddRange and RemoveAt methods. a StringCollection could do the same, oder? We don't need generic class when a specialiced class already exists. ;-) Gruss an Herrn Zingler
Show quote
Hide quote
"Alekszander Moses, Antifa-Rat Zureich" <ejpd.***@gmail.com> schrieb Thx. There are so many possibilites nowadays that not all of them come to my> On 27 Nov., 10:33, "Armin Zingler" <az.nos***@freenet.de> wrote: > > "Maurice van 't Loo" <nos...@nospam.nl> schrieb > > > > > > > > > > > > > Hi, > > > > > I'm pretty new with VB, especialy with 2008 Express :-p So i > > > need your help... > > > > > I have a text file containing: > > > > > VERSION 3 > > > ADDEDVERSION 5 > > > OPTION_GUILD_RECRUITMENT_CHANNEL AUTO > > > CHANNELS > > > guild 1 3 > > > dutchworld 1 4 > > > WorldTrade 1 5 > > > GMhelp 1 6 > > > END > > > ZONECHANNELS 16777216 > > > COLORS > > > SAY 255 255 255 > > > .... > > > .... > > > > > And i want to replace the part between CHANNELS and END > > > I allready found a way to read those lines and change it in the > > > way i want and put it in an array ( Dim channel_names(0 To 10) > > > As String ) > > > > > Now i want to replace those 4 lines with my array. > > > > > Does anyone has an idea to do this? > > > Or can anyone give me some hints or examples? > > > > Put 'em in a List(Of String) and you can remove and add items > > using the Add, AddRange and RemoveAt methods. > > Hi Armin, > > a StringCollection could do the same, oder? > > We don't need generic class when a specialiced class already > exists. ;-) mind immediatelly. :-) Though, a StringCollection is internally implemented as an Arraylist, so type casting has to be done each time an Item is returned. That's why I'd prefer the List(Of String). Armin
Disecting Strings
Call HTML control in code behind (ASP.net 2.0) Visual Studio 2005: VB fill circle automatic Can I write this program? OT - Vista Search and Recursive GetFiles Fastest way to import large fixed width file into a DataTable Setting up Policies to run Exe file from network drive DLL NOT FOUND (but only on certain systems???) Is setting Bounds Property the same as setting Size and Location? Multithreading Invoke Workaround |
|||||||||||||||||||||||