1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Remove Empty Line in Array String

Discussion in 'Visual Basic .NET' started by mixing, Dec 31, 2014.

  1. mixing

    mixing Regular Member

    Joined:
    Jan 18, 2014
    Messages:
    279
    Likes Received:
    33
    Gender:
    Male
    Location:
    USA
    Home Page:
    Hey everyone..I've got a textbox with 50 items in it. I'm putting those values into an array like this
    Code:
    Dim page = Me.txtNames.Lines.Cast(Of String).Skip(n * NumericUpDown1.Value).Take(NumericUpDown1.Value).ToArray()
    
    Once they're in the array, in putting them into a long string so I can separate them like this
    &name1=Mark&name2=John..etc
    Code:
    Dim s As String = String.Concat(Enumerable.Range(0, page.Count).Select(Function(x) "&name" & x.ToString & "=" & page(x)).ToArray)
    
    The problem is..if there's an empty line in the textbox, it gets put into the array..and ends up getting put into the string. Is there anyway I can alter one of the two above and remove any strings that are empty?
     
  2. Netro

    Netro Junior Member

    Joined:
    Jun 12, 2015
    Messages:
    107
    Likes Received:
    27
    Occupation:
    Baka Dev.
    yourtextbox.text = yourtexbox.text.replace(vbnewline, nothing)

    or

    yourtextbox.text.trim()