|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Space in textBoxHello
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.... 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.... > 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.... >> > > 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.... >>> >> 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.... >
Auto Increment Version in VB 2005
ToolBox Icon corruption VB2005 Transparent backcolor SqlDataAdapter Questions Thread safe TextWriter question How do I copy all text files into one??? eg; Shell("copy c:\CND\dr*.txt C:\CND\TestC.txx") Problem with System.IO.File.Move and Catching Exceptions Creating ToolWindows with .NET in VBE Select node Frame control is gobbling up my Listbox |
|||||||||||||||||||||||