none
From listbox to textbox with a space between RRS feed

  • Question

  • Hello,

    With this i put text from a listbox to a textbox , but how do i put a space between the text ?

      TextBox3.Lines = ListBox1.Items.Cast(Of String).ToArray

    Friday, June 23, 2017 4:48 PM

Answers

  • If you mean empty lines between the items, then:

    TextBox3.Lines = ListBox1.Items.Cast(Of String).SelectMany(Function(s) {s, ""}).ToArray

    Otherwise give details.

    Friday, June 23, 2017 5:33 PM

All replies

  • If you mean empty lines between the items, then:

    TextBox3.Lines = ListBox1.Items.Cast(Of String).SelectMany(Function(s) {s, ""}).ToArray

    Otherwise give details.

    Friday, June 23, 2017 5:33 PM
  • It would seem prudent to use .Text rather than Lines, with Lines I suspect you would want each item on a new line while by space use the Text property.

    TextBox3.Text = String.Join(" ", ListBox1.Items.Cast(Of String).ToArray)


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Friday, June 23, 2017 8:09 PM
    Moderator
  • Thanks it works.
    Saturday, June 24, 2017 5:19 AM