From: Carsten Beckermann on
Hello

I want to split several lines of text in the TXT file "d:\Names.txt"
They are seperated with an asterix (*).
Like that:
one*two
three*four
five*six
seven *eight


Please remember the added space after seven and after eight.
I want to search for "seven " with a trailing space and replace it with
"eight " with a trailing space.


I have tried that:

Const sNames = "d:\Names.txt"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oNames = oFSO.OpenTextFile(sNames)
aNames = Split(oNames.ReadAll, VbCrLf)


I tried for the last line:
aNames = Split(oNames.ReadAll, *, VbCrLf)

or:
aNames = Split(oNames.ReadAll, "*", VbCrLf)


How should the split command be changed to work for me?
If the asterix is impossible as a delimiter, i can replace the asterixes in
the textfile with another special char.


Greetings
Carsten


From: mayayana on
Why didn't you look at the help file? There
is only one delimiter in Split. If you want to
split it at vbCrLf and at "*" then that's two
operations. You need to go through the array
of lines split at vbCrLf and do a split on each
of those.

But you don't seem to be providing all of
the details here. The job you're describing
only requires s = Replace("seven *", NewString)


>
> I want to split several lines of text in the TXT file "d:\Names.txt"
> They are seperated with an asterix (*).
> Like that:
> one*two
> three*four
> five*six
> seven *eight
>
>
> Please remember the added space after seven and after eight.
> I want to search for "seven " with a trailing space and replace it with
> "eight " with a trailing space.
>
>
> I have tried that:
>
> Const sNames = "d:\Names.txt"
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> Set oNames = oFSO.OpenTextFile(sNames)
> aNames = Split(oNames.ReadAll, VbCrLf)
>
>
> I tried for the last line:
> aNames = Split(oNames.ReadAll, *, VbCrLf)
>
> or:
> aNames = Split(oNames.ReadAll, "*", VbCrLf)
>
>
> How should the split command be changed to work for me?
> If the asterix is impossible as a delimiter, i can replace the asterixes
in
> the textfile with another special char.
>
>
> Greetings
> Carsten
>
>


From: Petr Danes on
I don't think you need the split function at all, Carsten, unless there is
more subsequent processing that you didn't tell us about.

Something like this should be all you need.

x = oNames.ReadAll
x = Replace(x,"seven ","eight ")

Pete



"Carsten Beckermann" <derduron(a)web.de> p�se v diskusn�m pr�spevku
news:hi7db5$sa7$00$1(a)news.t-online.com...
> Hello
>
> I want to split several lines of text in the TXT file "d:\Names.txt"
> They are seperated with an asterix (*).
> Like that:
> one*two
> three*four
> five*six
> seven *eight
>
>
> Please remember the added space after seven and after eight.
> I want to search for "seven " with a trailing space and replace it with
> "eight " with a trailing space.
>
>
> I have tried that:
>
> Const sNames = "d:\Names.txt"
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> Set oNames = oFSO.OpenTextFile(sNames)
> aNames = Split(oNames.ReadAll, VbCrLf)
>
>
> I tried for the last line:
> aNames = Split(oNames.ReadAll, *, VbCrLf)
>
> or:
> aNames = Split(oNames.ReadAll, "*", VbCrLf)
>
>
> How should the split command be changed to work for me?
> If the asterix is impossible as a delimiter, i can replace the asterixes
> in the textfile with another special char.
>
>
> Greetings
> Carsten
>