Home All Groups Group Topic Archive Search About
Author
31 Jul 2006 10:00 PM
*.dpG
Hello
I have problem with this... In textBox I have some words with space
between for example
asdf  fhhhh      jjjjjkkkkk       oooooo
and space is not same between all word. I try to have only word in
listBox without space (or in new array) and i try this:
----------------------------------------------------------------------------
Dim stringNeki () As String = textBox.Split(" ")
For Each stringN As String In stringNeki
        If stringN <> " " Then
                lstBox.Items.Add(stringN)
            End If
Next
but dosen't work....

Can anybody help me, how to solve this.....

ThnX....

Author
31 Jul 2006 10:24 PM
Samuel Shulman
First replace all double spaces with single spaces like

s= textbox.text.replace("  ", " ")

you may have to loop a number of times like

s=textbox.text

For i - 0 to 10
s=s.replace("  ", " ")
Next

Then your method will remove the remaining single space

hth,
Samuel Shulman

Show quoteHide quote
"*.dpG" <fik***@yahoo.com> wrote in message
news:1154383231.713844.201260@i3g2000cwc.googlegroups.com...
> Hello
> I have problem with this... In textBox I have some words with space
> between for example
> asdf  fhhhh      jjjjjkkkkk       oooooo
> and space is not same between all word. I try to have only word in
> listBox without space (or in new array) and i try this:
> ----------------------------------------------------------------------------
> Dim stringNeki () As String = textBox.Split(" ")
> For Each stringN As String In stringNeki
>        If stringN <> " " Then
>                lstBox.Items.Add(stringN)
>            End If
> Next
> but dosen't work....
>
> Can anybody help me, how to solve this.....
>
> ThnX....
>
Author
1 Aug 2006 6:51 AM
HKSHK
Hello *.dbG, hello Samuel,

I would use this approach:

Dim s As String

s = TextBox1.Text

   While Instr(s, " ") > 0
   s = Replace(s, " ", "")
   End While

TextBox1.Text = s

Best Regards,

HKSHK

Samuel Shulman wrote:
Show quoteHide quote
> First replace all double spaces with single spaces like
>
> s= textbox.text.replace("  ", " ")
>
> you may have to loop a number of times like
>
> s=textbox.text
>
> For i - 0 to 10
> s=s.replace("  ", " ")
> Next
>
> Then your method will remove the remaining single space
>
> hth,
> Samuel Shulman
>
> "*.dpG" <fik***@yahoo.com> wrote in message
> news:1154383231.713844.201260@i3g2000cwc.googlegroups.com...
>> Hello
>> I have problem with this... In textBox I have some words with space
>> between for example
>> asdf  fhhhh      jjjjjkkkkk       oooooo
>> and space is not same between all word. I try to have only word in
>> listBox without space (or in new array) and i try this:
>> ----------------------------------------------------------------------------
>> Dim stringNeki () As String = textBox.Split(" ")
>> For Each stringN As String In stringNeki
>>        If stringN <> " " Then
>>                lstBox.Items.Add(stringN)
>>            End If
>> Next
>> but dosen't work....
>>
>> Can anybody help me, how to solve this.....
>>
>> ThnX....
>>
>
>
Author
1 Aug 2006 8:59 PM
Scott M.
That doesn't solve the problem that the OP posed.  What you've shown will
simply strip out all the spaces and create 1 resulting string.  The OP is
looking for many text values that were separated by one or more strings.
This does the trick:

Dim stringNeki () As String() = textBox.Text.Split(" ")
For Each stringN As String In stringNeki
       If stringN <> "" Then
               lstBox.Items.Add(stringN)
           End If
Next



Show quoteHide quote
"HKSHK" <hk***@gmx.net> wrote in message
news:44cef9f5$0$29356$9b622d9e@news.freenet.de...
> Hello *.dbG, hello Samuel,
>
> I would use this approach:
>
> Dim s As String
>
> s = TextBox1.Text
>
>   While Instr(s, " ") > 0
>   s = Replace(s, " ", "")
>   End While
>
> TextBox1.Text = s
>
> Best Regards,
>
> HKSHK
>
> Samuel Shulman wrote:
>> First replace all double spaces with single spaces like
>>
>> s= textbox.text.replace("  ", " ")
>>
>> you may have to loop a number of times like
>>
>> s=textbox.text
>>
>> For i - 0 to 10
>> s=s.replace("  ", " ")
>> Next
>>
>> Then your method will remove the remaining single space
>>
>> hth,
>> Samuel Shulman
>>
>> "*.dpG" <fik***@yahoo.com> wrote in message
>> news:1154383231.713844.201260@i3g2000cwc.googlegroups.com...
>>> Hello
>>> I have problem with this... In textBox I have some words with space
>>> between for example
>>> asdf  fhhhh      jjjjjkkkkk       oooooo
>>> and space is not same between all word. I try to have only word in
>>> listBox without space (or in new array) and i try this:
>>> ----------------------------------------------------------------------------
>>> Dim stringNeki () As String = textBox.Split(" ")
>>> For Each stringN As String In stringNeki
>>>        If stringN <> " " Then
>>>                lstBox.Items.Add(stringN)
>>>            End If
>>> Next
>>> but dosen't work....
>>>
>>> Can anybody help me, how to solve this.....
>>>
>>> ThnX....
>>>
>>
Author
1 Aug 2006 12:02 AM
Scott M.
The Split method works on a String, not a Textbox.  Also, the .Split(" ")
will cause all the spaces to be stripped out completely, so you don't want
to test for <> " ", you want to test for <> "".  The following code works
for me:

Dim stringNeki () As String() = textBox.Text.Split(" ")
For Each stringN As String In stringNeki
       If stringN <> "" Then
               lstBox.Items.Add(stringN)
           End If
Next


Show quoteHide quote
"*.dpG" <fik***@yahoo.com> wrote in message
news:1154383231.713844.201260@i3g2000cwc.googlegroups.com...
> Hello
> I have problem with this... In textBox I have some words with space
> between for example
> asdf  fhhhh      jjjjjkkkkk       oooooo
> and space is not same between all word. I try to have only word in
> listBox without space (or in new array) and i try this:
> ----------------------------------------------------------------------------
> Dim stringNeki () As String = textBox.Split(" ")
> For Each stringN As String In stringNeki
>        If stringN <> " " Then
>                lstBox.Items.Add(stringN)
>            End If
> Next
> but dosen't work....
>
> Can anybody help me, how to solve this.....
>
> ThnX....
>