[VB2008] How to replace lines in a textfile?

M

Maurice van 't Loo

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?

Thanks,
Maurice
 
A

Armin Zingler

Maurice van 't Loo said:
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.


Armin
 
A

Alekszander Moses, Antifa-Rat Zureich

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. ;-)

Gruss an Herrn Zingler
 
A

Armin Zingler

Alekszander Moses said:
Hi Armin,

a StringCollection could do the same, oder?

We don't need generic class when a specialiced class already
exists. ;-)


Thx. There are so many possibilites nowadays that not all of them come to my
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top