Results 1 to 4 of 4

Thread: [RESOLVED] Return an array of strings from itemarray

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    88

    Resolved [RESOLVED] Return an array of strings from itemarray

    Somehow I'm not really getting how to correctly use .ItemArray()

    I have a function that should return an array of strings.
    The array should be populated by a) a datacolumn or b) a fixed set (in case no data in datatable)

    VB Code:
    1. Function SubExtensions() As Array
    2.         'Set the user defined Extentionlist
    3.         'When a custom list is saved it is loaded into table "Extenions" during startup (LoadSettings())
    4.         'If the list is empty populate with hardcoded list
    5.         Dim tbl As DataTable = frmMain.dsProgramSettings.Tables.Item("Extensions")
    6.         Dim row As DataRow
    7.         Dim item As String
    8.         Dim arrList() As String = {".mpg", ".avi", ".mov", ".wmv", ".iso", ".bin", ".nrg", ".mp4", ".img", ".bup"}
    9.  
    10.         If tbl.Rows.Count > 0 Then
    11.             Return tbl.Rows.Item("Extension").ItemArray
    12.         Else 'Populate dataset table
    13.             For Each item In arrList ' fill datatable
    14.                 row = tbl.NewRow
    15.                 row("Extension") = item.ToString.ToLower
    16.                 tbl.Rows.Add(row)
    17.             Next
    18.             Return arrList
    19.         End If
    20.     End Function

    Itemarray returns an index of integers, but I want a list of strings (column "Extension"). How should I do that ?
    Last edited by SammyWaslow; Apr 2nd, 2006 at 05:02 AM.
    Using Visual Studio 2005 / Framework 2.0

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    88

    Re: Having troubles understanding/using ItemArray()

    Anyone ?
    Using Visual Studio 2005 / Framework 2.0

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    88

    Re: Having troubles understanding/using ItemArray()

    This line is giving me headaches

    VB Code:
    1. Return tbl.Rows.Item("Extension").ItemArray

    Can anyone point me in the right direction on how to return an array (of strings) in this case ?
    Using Visual Studio 2005 / Framework 2.0

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    88

    Resolved Re: Having troubles understanding/using ItemArray()

    Surely someone can help me out ?


    EDIT:
    never mind. I realize I was looking at the wrong thing all along. itemarray returns and array of the columns in a row, whereas I want one column from all the rows. A loop it is then ...

    Though strange i didn't get a reply on this one ...
    Last edited by SammyWaslow; Apr 2nd, 2006 at 05:01 AM.
    Using Visual Studio 2005 / Framework 2.0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width