Results 1 to 4 of 4

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

Threaded View

  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

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