split a string into an arraylist?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mad Scientist Jr

    #1

    split a string into an arraylist?

    If I try splitting a string into an arraylist

    Dim arrList As New ArrayList
    arrList = Split("a,b,c", ",")

    I get this error: Value of type '1-dimensional array of String' cannot
    be converted to 'System.Collect ions.ArrayList' .

    How can I split a string into an arraylist?

    Thanks

  • Armin Zingler

    #2
    Re: split a string into an arraylist?

    "Mad Scientist Jr" <usenet_daughte r@yahoo.com> schrieb[color=blue]
    > If I try splitting a string into an arraylist
    >
    > Dim arrList As New ArrayList
    > arrList = Split("a,b,c", ",")
    >
    > I get this error: Value of type '1-dimensional array of String'
    > cannot be converted to 'System.Collect ions.ArrayList' .
    >
    > How can I split a string into an arraylist?[/color]

    arrlist.addrang e(Split("a,b,c" , ","))



    Armin

    Comment

    • Phill  W.

      #3
      Re: split a string into an arraylist?

      "Mad Scientist Jr" <usenet_daughte r@yahoo.com> wrote in message
      news:1140024654 .685793.41310@g 44g2000cwa.goog legroups.com...[color=blue]
      > If I try splitting a string into an arraylist
      >
      > Dim arrList As New ArrayList
      > arrList = Split("a,b,c", ",")
      >
      > I get this error: Value of type '1-dimensional array of String' cannot
      > be converted to 'System.Collect ions.ArrayList' .[/color]

      Aren't Constructors Wonderful things?

      Creating a new ArrayList /based on/ a String array:

      Dim arrList As New ArrayList( "a,b,c".Spl it( ","c ) )

      or, to split by a multiple-character delimiter:

      Imports VB=Microsoft.Vi sualBasic

      Dim arrList As New ArrayList( VB.Split( "a<>b<>c", "<>" ) )

      HTH,
      Phill W.


      Comment

      Working...