Home All Groups Group Topic Archive Search About
Author
8 Sep 2010 1:08 AM
SIS01
Hi,

Please helpme

I want to split this line:

string line = "Davis  ,   Jones, Beckett   ,  Jordan  , Kennt  "

into an array of their trimmed versions:

"Davis"
"Jones"
"Beckett"
"Jordan"
"Kennt"


I've tried several soluctions but none resolves it.

Dim linea As String = "Davis  ,   Jones, Beckett   ,  Jordan  , Kennt  "
Dim delimiter As String = ","
Dim nombress As String() = linea.Split(delimiter.ToCharArray())



Array.ForEach(nombress, Function(p) p.Trim())  ' does not work
Array.ForEach(nombress, Function(p) WriteLine("action: -" & p & " - "))


Array.ConvertAll(nombress, New Converter(Of String, String)(Function(c)
c.Trim()))   ' does not work
Array.ForEach(nombress, Function(p) WriteLine("action: -" & p & " - "))


For Each n In nombress
    n = n.Trim        ' does not work
Next
Array.ForEach(nombress, Function(p) WriteLine("action: -" & p & " - "))

Author
8 Sep 2010 1:28 AM
Karl E. Peterson
SIS01 formulated the question :
> I've tried several soluctions but none resolves it.

If you wanna try a VB solution, this would be the place.  Given what
you're trying, I'd suggest you find another venue to post the question.

--
..NET: It's About Trust!
http://vfred.mvps.org
Author
8 Sep 2010 1:43 AM
Ron Weiner
SIS01 explained on 9/7/2010 :
Show quoteHide quote
> Hi,
>
> Please helpme
>
> I want to split this line:
>
> string line = "Davis  ,   Jones, Beckett   ,  Jordan  , Kennt  "
>
> into an array of their trimmed versions:
>
> "Davis"
> "Jones"
> "Beckett"
> "Jordan"
> "Kennt"
>
>
> I've tried several soluctions but none resolves it.
>
> Dim linea As String = "Davis  ,   Jones, Beckett   ,  Jordan  , Kennt  "
> Dim delimiter As String = ","
> Dim nombress As String() = linea.Split(delimiter.ToCharArray())
>
>
>
> Array.ForEach(nombress, Function(p) p.Trim())  ' does not work
> Array.ForEach(nombress, Function(p) WriteLine("action: -" & p & " - "))
>
>
> Array.ConvertAll(nombress, New Converter(Of String, String)(Function(c)
> c.Trim()))   ' does not work
> Array.ForEach(nombress, Function(p) WriteLine("action: -" & p & " - "))
>
>
> For Each n In nombress
>     n = n.Trim        ' does not work
> Next
> Array.ForEach(nombress, Function(p) WriteLine("action: -" & p & " - "))

If you were using VB this would work
    Dim a() As String
    Dim i As Integer

    a = Split("Davis  ,   Jones, Beckett   ,  Jordan  , Kennt  ", ",")
    For i = 0 To UBound(a)
        a(i) = Trim(a(i))
    Next
    For i = 0 To UBound(a)
        Debug.Print ">"; a(i); "<"
    Next
But it appears that you are using some other language.  Sorry we'll not
be able to help you here.

Rdub
Author
8 Sep 2010 2:47 AM
Nobody
This group is for VB6 and earlier(VB Classic). VB.Net and all dotnet groups
have either "dotnet" or "vsnet" in the group name. Please use the following
group instead:

news://news.aioe.org/microsoft.public.dotnet.languages.vb
Author
8 Sep 2010 2:59 AM
Kevin Provance
"Nobody" <nob***@nobody.com> wrote in message
news:i66tg9$qg1$1@speranza.aioe.org...
: This group is for VB6 and earlier(VB Classic). VB.Net and all dotnet
groups
: have either "dotnet" or "vsnet" in the group name. Please use the
following
: group instead:
:
: news://news.aioe.org/microsoft.public.dotnet.languages.vb
:

aioe, the usenet spammers haven...that's what the cowards use.  Considering
your support of it, this comes s no surprise.  Right....Bill?
Author
8 Sep 2010 3:28 PM
DickGrier
Well, in VB:

Dim myString as String
myString = "Davis  ,   Jones, Beckett   ,  Jordan  , Kennt  "
Dim myStringArray() As String
myString = Replace(myString, " ", "" )   'if you don't want the spaces
myStringArray = Split(myString, ",")

That's as close as we are going to get to answering your (somewhat nebulous)
question.

Dick

--
Richard Grier, Consultant, Hard & Software 12962 West Louisiana Avenue
Lakewood, CO 80228 303-986-2179 (voice) Homepage: www.hardandsoftware.net
Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004, Revised July
2006.
Author
8 Sep 2010 4:31 PM
Cor
Dick,

Nobody gave him a link to the vb.Net newsgroup.
The Op got his answers there, I've also placed a very compressed version
like yours in that newsgroup.

Cor

"DickGrier"  wrote in message news:O$vBFq2TLHA.620@TK2MSFTNGP06.phx.gbl...

Well, in VB:

Dim myString as String
myString = "Davis  ,   Jones, Beckett   ,  Jordan  , Kennt  "
Dim myStringArray() As String
myString = Replace(myString, " ", "" )   'if you don't want the spaces
myStringArray = Split(myString, ",")

That's as close as we are going to get to answering your (somewhat nebulous)
question.

Dick

--
Richard Grier, Consultant, Hard & Software 12962 West Louisiana Avenue
Lakewood, CO 80228 303-986-2179 (voice) Homepage: www.hardandsoftware.net
Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004, Revised July
2006.
Author
8 Sep 2010 4:52 PM
Mike Williams
"Cor" <Notmyfirstn***@planet.nl> wrote in message
news:OO3n8M3TLHA.4344@TK2MSFTNGP02.phx.gbl...

> Nobody gave him a link to the vb.Net newsgroup.

Yes they did :-)

Mike
Author
8 Sep 2010 5:40 PM
MikeD
"DickGrier" <dick_grierNOSPAM@msn.com> wrote in message
news:O$vBFq2TLHA.620@TK2MSFTNGP06.phx.gbl...
> Well, in VB:
>
> Dim myString as String
> myString = "Davis  ,   Jones, Beckett   ,  Jordan  , Kennt  "
> Dim myStringArray() As String
> myString = Replace(myString, " ", "" )   'if you don't want the spaces
> myStringArray = Split(myString, ",")

I would not do the replace for the space character.  If you do what you're
suggesting, a name like "Van Halen" would end up being "VanHalen".
Instead, do the Split first and then if desired use Trim$() to eliminate
leading and trailing spaces. Of course, this means you'd need to trim the
spaces on a per-array-element basis, but at least you're not altering the
data.

--
Mike
Author
9 Sep 2010 6:23 AM
Cor
Did you visit the dotnet group where the OP wrote that.

However, that was not the question (take the time to look at the original
message).

It reminds me that once somebody asked me where the power on button of his
home computer was.

I showed him that and than he said: "Yes but if I am not home, how can I
then power up that computer"

Cor

"MikeD"  wrote in message news:i68hqm$gk$1@news.eternal-september.org...



"DickGrier" <dick_grierNOSPAM@msn.com> wrote in message
news:O$vBFq2TLHA.620@TK2MSFTNGP06.phx.gbl...
> Well, in VB:
>
> Dim myString as String
> myString = "Davis  ,   Jones, Beckett   ,  Jordan  , Kennt  "
> Dim myStringArray() As String
> myString = Replace(myString, " ", "" )   'if you don't want the spaces
> myStringArray = Split(myString, ",")

I would not do the replace for the space character.  If you do what you're
suggesting, a name like "Van Halen" would end up being "VanHalen".
Instead, do the Split first and then if desired use Trim$() to eliminate
leading and trailing spaces. Of course, this means you'd need to trim the
spaces on a per-array-element basis, but at least you're not altering the
data.

--
Mike
Author
9 Sep 2010 12:51 PM
MikeD
Show quote Hide quote
"Cor" <Notmyfirstn***@planet.nl> wrote in message
news:eKXaKe#TLHA.3748@TK2MSFTNGP05.phx.gbl...
> Did you visit the dotnet group where the OP wrote that.
>
> However, that was not the question (take the time to look at the original
> message).
>
> It reminds me that once somebody asked me where the power on button of his
> home computer was.
>
> I showed him that and than he said: "Yes but if I am not home, how can I
> then power up that computer"
>
> Cor


What the hell does this have to do with anything?
Author
9 Sep 2010 1:39 PM
Cor
Show quote Hide quote
"MikeD"  wrote in message news:i6al96$9eb$1@news.eternal-september.org...



"Cor" <Notmyfirstn***@planet.nl> wrote in message
news:eKXaKe#TLHA.3748@TK2MSFTNGP05.phx.gbl...
> Did you visit the dotnet group where the OP wrote that.
>
> However, that was not the question (take the time to look at the original
> message).
>
> It reminds me that once somebody asked me where the power on button of his
> home computer was.
>
> I showed him that and than he said: "Yes but if I am not home, how can I
> then power up that computer"
>
> Cor


What the hell does this have to do with anything?
-------------------------------------------------------------------------
Yes that was I asking myself as well on your reply to Dick.

The OP did asked how to get the spaces removed after and before a comma in a
CSV string.

What if it had been,

"van der Bilt, J.m.k  ;  Jensen, G, ;  Du Pen, P.   " in a non English
language CSV string

The same question, which is based on the follow up question from the OP in
the dotNet newsgroup.
Not relevant for a true developer, he has to solve problems, not all kind of
imaginary problems.
(Which I had also ones when somebody asked: "Does it also work if a atomic
bomb explode above my office?)

The Op had already followed the advice from nobody here, my reply was only
meant for Dick to inform him especially about his message.

Cor
\
Author
10 Sep 2010 7:10 PM
J.C.
> (Which I had also ones when somebody asked: "Does it also work if a atomic
> bomb explode above my office?)

No, the question is: "If Cor passes gas in his office, will there be any
survivors?".


Show quoteHide quote
"Cor" <Notmyfirstn***@planet.nl> wrote in message
news:OmcChRCULHA.4980@TK2MSFTNGP04.phx.gbl...
>
> "MikeD"  wrote in message news:i6al96$9eb$1@news.eternal-september.org...
>
>
>
> "Cor" <Notmyfirstn***@planet.nl> wrote in message
> news:eKXaKe#TLHA.3748@TK2MSFTNGP05.phx.gbl...
>> Did you visit the dotnet group where the OP wrote that.
>>
>> However, that was not the question (take the time to look at the original
>> message).
>>
>> It reminds me that once somebody asked me where the power on button of
>> his home computer was.
>>
>> I showed him that and than he said: "Yes but if I am not home, how can I
>> then power up that computer"
>>
>> Cor
>
>
> What the hell does this have to do with anything?
> -------------------------------------------------------------------------
> Yes that was I asking myself as well on your reply to Dick.
>
> The OP did asked how to get the spaces removed after and before a comma in
> a CSV string.
>
> What if it had been,
>
> "van der Bilt, J.m.k  ;  Jensen, G, ;  Du Pen, P.   " in a non English
> language CSV string
>
> The same question, which is based on the follow up question from the OP in
> the dotNet newsgroup.
> Not relevant for a true developer, he has to solve problems, not all kind
> of imaginary problems.
> (Which I had also ones when somebody asked: "Does it also work if a atomic
> bomb explode above my office?)
>
> The Op had already followed the advice from nobody here, my reply was only
> meant for Dick to inform him especially about his message.
>
> Cor
> \
Author
10 Sep 2010 7:34 PM
Kevin Provance
Show quote Hide quote
"Cor" <Notmyfirstn***@planet.nl> wrote in message
news:OmcChRCULHA.4980@TK2MSFTNGP04.phx.gbl...
: -------------------------------------------------------------------------
: Yes that was I asking myself as well on your reply to Dick.
:
: The OP did asked how to get the spaces removed after and before a comma in
a
: CSV string.
:
: What if it had been,
:
: "van der Bilt, J.m.k  ;  Jensen, G, ;  Du Pen, P.   " in a non English
: language CSV string
:
: The same question, which is based on the follow up question from the OP in
: the dotNet newsgroup.
: Not relevant for a true developer, he has to solve problems, not all kind
of
: imaginary problems.
: (Which I had also ones when somebody asked: "Does it also work if a atomic
: bomb explode above my office?)
:
: The Op had already followed the advice from nobody here, my reply was only
: meant for Dick to inform him especially about his message.

Just STFU and go away already.  It takes more work to figure out what you
are saying than anything else.  And even then you make little to no sense.
Author
9 Sep 2010 12:51 PM
Paul Clement
On Tue, 7 Sep 2010 20:08:22 -0500, "SIS01" <si***@msf.org.mx> wrote:

¤ Hi,
¤
¤ Please helpme
¤
¤ I want to split this line:
¤
¤ string line = "Davis  ,   Jones, Beckett   ,  Jordan  , Kennt  "
¤
¤ into an array of their trimmed versions:
¤
¤ "Davis"
¤ "Jones"
¤ "Beckett"
¤ "Jordan"
¤ "Kennt"
¤
¤
¤ I've tried several soluctions but none resolves it.
¤
¤ Dim linea As String = "Davis  ,   Jones, Beckett   ,  Jordan  , Kennt  "
¤ Dim delimiter As String = ","
¤ Dim nombress As String() = linea.Split(delimiter.ToCharArray())
¤

Try posting your question to the Visual Basic General forum:

http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/threads?page=1


Paul
~~~~
Microsoft MVP (Visual Basic)
Author
9 Sep 2010 2:04 PM
Mayayana
| Try posting your question to the Visual Basic General forum:
|
| http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/threads?page=1
|

  It was answered yesterday in the VB.Net
group. If you're going to hang directing people
to MS forums, you could at least follow what's
happening on Usenet. (I know the VB.Net
group is "no longer supported" by MS. But it's
being used, so your posts are becoming out
of touch.)
Author
10 Sep 2010 12:11 PM
Paul Clement
On Thu, 9 Sep 2010 10:04:11 -0400, "Mayayana" <mayayana@invalid.nospam> wrote:

¤
¤ | Try posting your question to the Visual Basic General forum:
¤ |
¤ | http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/threads?page=1
¤ |
¤
¤   It was answered yesterday in the VB.Net
¤ group. If you're going to hang directing people
¤ to MS forums, you could at least follow what's
¤ happening on Usenet. (I know the VB.Net
¤ group is "no longer supported" by MS. But it's
¤ being used, so your posts are becoming out
¤ of touch.)
¤

I don't need to know what is going on in other support newsgroups or forums and I'm certainly not
going to check them. The forum link was posted as an alternative resource, one with considerably
more activity I might add, and it's rather petty to quibble about it.

If you're inviting me to continue on in this newsgroup after Microsoft has shut down their servers
(within the next month), then I appreciate the thought.


Paul
~~~~
Microsoft MVP (Visual Basic)
Author
9 Sep 2010 2:34 PM
Mike Williams
"Paul Clement" <UseAdddressAtEndofMess***@swspectrum.com> wrote in message
news:11mh865798vqhh4ns3655oetlsnvh9s6jj@4ax.com...
> Try posting your question to the Visual Basic General forum:
> http://social.msdn.micro$oft.com/PlayRoomForums/en-US/vbgeneral/threads?page=1

Still the same old troll.
Author
10 Sep 2010 12:21 PM
Paul Clement
On Thu, 9 Sep 2010 15:34:16 +0100, "Mike Williams" <M***@WhiskyAndCoke.com> wrote:


¤ Still the same old troll.
¤

That you are. Thanks for the reminder. ;-)


Paul
~~~~
Microsoft MVP (Visual Basic)
Author
9 Sep 2010 2:44 PM
Cor
Paul,

Will you be so kind next time to add a text like "non VB6" questions (or
whatever text).

I become sad of redirecting (if this newsgroup is not in a bad acting mood)
all forum post for VB6 again to this newsgroup.

You know, your text comes in search engines.

Cor

"Paul Clement"  wrote in message
news:11mh865798vqhh4ns3655oetlsnvh9s6jj@4ax.com...

On Tue, 7 Sep 2010 20:08:22 -0500, "SIS01" <si***@msf.org.mx> wrote:

¤ Hi,
¤
¤ Please helpme
¤
¤ I want to split this line:
¤
¤ string line = "Davis  ,   Jones, Beckett   ,  Jordan  , Kennt  "
¤
¤ into an array of their trimmed versions:
¤
¤ "Davis"
¤ "Jones"
¤ "Beckett"
¤ "Jordan"
¤ "Kennt"
¤
¤
¤ I've tried several soluctions but none resolves it.
¤
¤ Dim linea As String = "Davis  ,   Jones, Beckett   ,  Jordan  , Kennt  "
¤ Dim delimiter As String = ","
¤ Dim nombress As String() = linea.Split(delimiter.ToCharArray())
¤

Try posting your question to the Visual Basic General forum:

http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/threads?page=1


Paul
~~~~
Microsoft MVP (Visual Basic)