Skip to main content

listbox to concatenated string

Comments

5 comments

  • Ryan Kelley

    You need to cast the variable from your output in your form where the multi-selection takes place to an IList<Object> variable.

    Then, Assign a str variable (x ) to  an empty str= ""

    Then, do a For Each <Object> and use the cast variable mentioned above.

    Put an Assign activity in the body of the For Each where the string variable x  = item + "," + x

    You'll end up with a list that ends in ",", which you can just take out determining the length of x. Ex: finalString =  Left(x,Len(x)-1)

    0
  • Dan Griffin

    Thanks for your help Ryan.

    I am getting an error on the Assign activity x = item + "," + x

    Option Strict On prohibits operands of type Object for operator '+'

    0
  • Dan Griffin

    Looks like I just needed to add.

    x = item.toString + "," + x

    Thanks again.

    0
  • Permanently deleted user

    fyi,

    it will be much safter and faster (?) with

    x = string.format("{0}, {1}", item, x)

    0
  • Nico Burgerhart

     

    Import System.Linq and use the following to create a valid where clause:

    string.Format("columname IN ({0})",String.Join(",", CType(listvar, IList(Of Object)).Select(Function(value) "'" & value.ToString & "'")))

    Change columnname to the column name in your data.

     

    listvar is the object returned from the listbox.

     

     
    0

Please sign in to leave a comment.