[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:
Function SubExtensions() As Array
'Set the user defined Extentionlist
'When a custom list is saved it is loaded into table "Extenions" during startup (LoadSettings())
'If the list is empty populate with hardcoded list
Dim tbl As DataTable = frmMain.dsProgramSettings.Tables.Item("Extensions")
Dim row As DataRow
Dim item As String
Dim arrList() As String = {".mpg", ".avi", ".mov", ".wmv", ".iso", ".bin", ".nrg", ".mp4", ".img", ".bup"}
If tbl.Rows.Count > 0 Then
Return tbl.Rows.Item("Extension").ItemArray
Else 'Populate dataset table
For Each item In arrList ' fill datatable
row = tbl.NewRow
row("Extension") = item.ToString.ToLower
tbl.Rows.Add(row)
Next
Return arrList
End If
End Function
Itemarray returns an index of integers, but I want a list of strings (column "Extension"). How should I do that ?
Re: Having troubles understanding/using ItemArray()
Re: Having troubles understanding/using ItemArray()
This line is giving me headaches
VB Code:
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 ?
Re: Having troubles understanding/using ItemArray()
Surely someone can help me out ? :ehh:
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 ...